LCM of 2 Numbers


WAP to find LCM of two integer.

import java.util.Scanner;
class L17LCMof2No
{
   public static void main()
   {
      int x, y;
      System.out.println("Enter two integers to calculate their Lowest Common Multiple");
      Scanner in = new Scanner(System.in);
      x = in.nextInt();
      y = in.nextInt();
      int lcm=1;
      while(lcm % x !=0 ||  lcm % y !=0)
      lcm ++;
      
      System.out.println("LCM of integers "+x+" and "+y +" is "+lcm);
   }
}

Comments

Popular Posts