0

Any one help me how write 10th perfect number using big integer in Java

13th Jan 2023, 2:14 PM
Srinivas vedullapalli
Srinivas vedullapalli - avatar
2 Respuestas
+ 2
What have you tried so far?
20th Jan 2023, 3:25 PM
Denise Roßberg
Denise Roßberg - avatar
0
public class Program { public static void main(String[] args) { for(long i=1;i<=100000000;i++){ long temp=i; long sum = 0; for(long j=1;j<temp;j++) { if(temp%j==0){ sum = sum+j; } } if(sum == i){ System .out .println (i); } } } } I'm tried to find first 10 perfect number using above code but I'm get few perfect numbers, i want to 10 perfect numbers, i don't know which keyword use to get my output.
23rd Jan 2023, 1:31 PM
Srinivas vedullapalli
Srinivas vedullapalli - avatar