Computer Science, asked by devpxs, 7 months ago

Write a java program to input 3 numbers of integer type and print their LCM.
will give brillinest if ans is correct

Answers

Answered by kamalsen519
0

Answer:

public class Main {

public static void main(String[] args) {

int n1 = 72, n2 = 120, lcm;

// maximum number between n1 and n2 is stored in lcm

lcm = (n1 > n2) ? n1 : n2;

// Always true

while(true) {

if( lcm % n1 == 0 && lcm % n2 == 0 ) {

System.out.printf("The LCM of %d and %d is %d.", n1, n2, lcm);

break;

}

++lcm;

}

}

}

Output

The LCM of 72 and 120 is 360.

Similar questions