forked from ghostmkg/programming-language
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerfect.java
35 lines (34 loc) · 800 Bytes
/
Perfect.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
import java.util.*;
class Perfect
{
void check(int s,int k,int n)
{
if(k==n)
{
if(s==n)
System.out.print("perfect no.");
else
System.out.print("Not perfect");
return;
}
else
{
if(n%k==0)
{
s=s+k;
check(s,++k,n);
}
else
check(s,++k,n);
}
}
public static void main()
{
Scanner sc=new Scanner(System.in);
Perfect ob=new Perfect();
int no;
System.out.println("Enter number");
no=sc.nextInt();
ob.check(0,1,no);
}
}