DEV Community

hema latha
hema latha

Posted on

LCM - Program find out least common multiple

package day1;

public class LCM {

public static void main(String[] args) {
    // TODO Auto-generated method stub
 int no1 = 3;
 int no2 = 517;
 int big = 0; 
 if (no1>no2)
     big = no1;
 else 
     big = no2;

 while(true) {
    if(big%no1==0 && big%no2==0)
     {
         System.out.println("LCM is " +big);
         break;          
     }
 big= big+1;                 
}}}
Enter fullscreen mode Exit fullscreen mode

out put === LCM is 1551

Top comments (0)