-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCM
36 lines (31 loc) · 729 Bytes
/
LCM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package practice;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class rough
{
public static void main(String args[])
{
int n1 = 2, n2 = 3;
List<Integer> list = new ArrayList<>();
int g = (n1>n2)?n1:n2;
for(;;)
{
if(g%n1==0 && g%n2==0)
{
list.add(g);
break;
}
else
++g;
}
Iterator iterate = list.iterator();
while(iterate.hasNext())
System.out.print(iterate.next()+"\t");
}
}