Finding HCF and LCM of Two Numbers In Java

Write a program to LCM and HCF of two integers.   import java.io.*; class HCM { int a,b,num,hcd,hcm; void lcm() { a=Integer.parseInt(System.console().readLine(“enter the first no.=”)); b=Integer.parseInt(System.console().readLine(“enter the 2nd   no.=”)); int m=a*b; if(a>b) { num=a; } else { num=b; } for (int i = 1; i <= num; i++) { if ((a%i==0) && (b%i==0)) { hcd=i; […] Continue reading →

Fibonacci Series In Java

Fibonacci series in Java In fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. The first two numbers of fibonacci series are 0 and 1.Let’s see the fibonacci series program in java         import java.io.*; class FibonacciExample […] Continue reading →

Palindrome Strings in Java

     Palindrome Strings in Java:   Exapmle of Palindrome Strings are Liril, Radar, Level, Mom, Dad, Malayalam, Civic, Madam, Bob, Pop, Refer, Rotator, Stats.     Example Java Program to check whether a given number or string is palindrome or not import java.util.*; public class PalindromeSt { public static void main(String[] args) { Scanner […] Continue reading →

Palindrome Number In Java

      Palindrome number in java:       A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers.When we reverse 545 same after reverse 545.           import java.io.*; import java.util.*; class Palindrome { public static void […] Continue reading →
Page 1 of 43123456»102030...Last »