-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_13.java
66 lines (58 loc) · 1.28 KB
/
Q_13.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package New;
import java.util.Scanner;
public class Qu_13 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n;
int hcf=0;
System.out.println("Enter the number of pairs");
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int[][] arr=new int[n][2];
System.out.println("Enter a and b for each pair");
for(int i=0;i<n;i++) {
arr[i][0]=sc.nextInt();
arr[i][1]=sc.nextInt();
}
for(int i=0;i<n;i++) {
if(arr[i][0]<arr[i][1]) {
System.out.println("b is greater than a");
}
if(arr[i][0]>arr[i][1]) {
System.out.println("a is greater than b");
}
if(arr[i][0]%2==0 && arr[i][1]%2==0) {
System.out.println("Both a and b are even");
}
else {
System.out.println("Both a and b are not even");
}
for(int j = 1; j <= arr[i][0] || j <= arr[i][1]; j++) {
if( arr[i][0]%j == 0 && arr[i][1]%j == 0 ) {
hcf = j;
}
}
if(hcf==1) {
System.out.println("Relatively Prime");
}
else {
System.out.println("Not Relatively Prime");
}
}
}
}
/*Output
Enter the number of pairs
2
Enter a and b for each pair
1
4
2
6
b is greater than a
Both a and b are not even
Relatively Prime
b is greater than a
Both a and b are even
Not Relatively Prime
*/