Datasets:

ArXiv:
License:
File size: 592 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class LCM {
    public static void main(String[] args) {

        int n1,n2,LCM;
        Scanner s = new Scanner(System.in);
        
        System.out.print("Enter the integer 1: ");
        n1 = s.nextInt();

        System.out.print("Enter the integer 2: ");
        n2 = s.nextInt();
        
        LCM = (n1 > n2) ? n1 : n2;
        
        while(true) {
            if( LCM % n1 == 0 && LCM % n2 == 0 ) {
                System.out.printf("The Least Common Multiplier of %d and %d : %d", n1, n2, LCM);
                break;
            }
            ++LCM;
        }
    }
}