0
Any one help me how write 10th perfect number using big integer in Java
2 Réponses
+ 2
What have you tried so far?
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.