Computer Science, asked by shiva735, 10 months ago

page
WAP to check whether a no.
a perfect no. without twing
I do while,​

Answers

Answered by aman7913
3

public class Perfect.

int n, sum = 0;

Scanner s = new Scanner(System.

System. out. print("Enter any integer you want to check:");

n = s. nextInt();

for(int i = 1; i < n; i++)

if(n % i == 0)

sum = sum + i;

____________________________

hope it helps you

Answered by anindyaadhikari13
24

Here is your answer.

&lt;hr/&gt;

class x

{

static void main(int n)

{

int s=0;

for(int i=1;i<n;i++)

{

if(n%i==0)

s=s+i;

}

if(s==n)

System.out.println("Number is a perfect number. ");

else

System.out.println(" Number is not a perfect number. ");

}

}

&lt;hr/&gt;

Similar questions