Page 309 - CA_Blue( J )_Class10
P. 309
8 }
9 void input()
10 {
11 Scanner sc= new Scanner(System.in);
12 System.out.print("Enter a number : ");
13 n=sc.nextInt();
14 }
15 void isperfect()
16 {
17 int i,s=0;
18 for(i=1;i<=n/2;i++)
19 {
20 if(n%i==0)
21 {
22 s=s+i;
23 }
24 }
25 if(s==n)
26 System.out.println(n + " is a perfect Number");
27 else
28 System.out.println(n+ " is not a perfect number");
29 }
30
31 public static void main()
32 {
33 Perfect ob = new Perfect();
34 ob.input();
35 ob.isperfect();
36 }
36 }
You will get the following output:
307
Constructors 307

