-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlay4.java
More file actions
61 lines (49 loc) · 1.31 KB
/
Copy pathPlay4.java
File metadata and controls
61 lines (49 loc) · 1.31 KB
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
import java.util.*;
public class Play4{
public static int divsum(int a){
int sum = 0;
for(int i = 1;i<a;i++){
if(a %i == 0){
sum += i;
}
}
return sum;
}
public static boolean isamicable(int a,int b){
int asum = divsum(a)/a;
int bsum = divsum(b)/b;
if(asum == bsum)return true;
return false;
}
public static boolean isabundant(int a){
int sum = divsum(a);
if(sum == a)return true;
return false;
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("enter first number :");
int a = sc.nextInt();
System.out.println("enter 2nd number:");
int b = sc.nextInt();
boolean ans = isamicable(a,b);
if(ans == true){
System.out.println("nuber are amicable or friendly!");
}
else{
System.out.println("numbers are not friendly!");
}
if(isabundant(a)){
System.out.println("number"+a+" is abundant :");
}
else{
System.out.println("number"+a+"is not abundant :");
}
if(isabundant(b)){
System.out.println("number"+b+" is abundant :");
}
else{
System.out.println("number"+b+"is not abundant :");
}
}
}