-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQUIZ_1_01.java
More file actions
37 lines (20 loc) · 734 Bytes
/
QUIZ_1_01.java
File metadata and controls
37 lines (20 loc) · 734 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
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class QUIZ_1_01{
public static void main(String[] args) {
int min = 50;
int max = 150;
int n_1 = (int) (min + Math.random() * (max - min + 1));
int n_2 = (int) (min + Math.random() * (max - min + 1));
System.out.println("The two randomly generated numbers are: " + n_1 + " and " + n_2);
int sum = 0;
System.out.print("Their common divisor are: ");
for (int i = 1; i < n_1; i++){
if ((n_1 % i == 0) && (n_2 % i == 0) ){
System.out.print( i + " " );
sum += i;
}
}
System.out.println();
System.out.println("Sum of the common divisor is: " + sum);
}
}