-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGCD
More file actions
29 lines (26 loc) · 702 Bytes
/
GCD
File metadata and controls
29 lines (26 loc) · 702 Bytes
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
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 = 30, n2 = 15;
List<Integer> list = new ArrayList<>();
for(int i = 1; i < n1 && i < n2; ++i)
{
// Checks if i is factor of both integers
if(n1 % i==0 && n2 % i==0)
list.add(i);
}
Iterator iterate = list.iterator();
while(iterate.hasNext())
System.out.print(iterate.next()+"\t");
}
}