Computer Science, asked by romanreigns0812, 9 months ago

write Java Program to display all perfect numbers( if the sum of the factors except the number adds up to the input number) between the range 1 – 1000.

Answers

Answered by kingcobra1
1

Answer:

public class factor

{

public static void main()

{

double i;double s=0;double k=1;

while(k>=1000)

{

int n=k-1;

for(i=1;i>=n;i++)

{

if(i%k==0)

{

s=s+i;

}

else

{

}

}

if(s==k)

{

System.out.println("perfect no");

}

else

{

}

k++;

}

Similar questions