public class PerfectNumbers{
public static void main(String[]args){
//Specifying the intervals of numbers
for(int i=1; i<10000; i++){
int sum = 0;
for(int divisors=1; i/2>=divisors; divisors++){
//Finding the remainding
int result = i%divisors;
if(result==0){
sum+=divisors;
}
}
if(sum==i){
System.out.println(sum);
}
}
}
}
Hiç yorum yok:
Yorum Gönder