int main(int argc, char ** argv)
{
int i;
int a;
int total;
total = 0;
int tep[100] ={};
int * ptr = tep;
for(i = 1; i <= 10000; i ++ )
{
for(a = 1; a < i; a++)
{
if(i % a == 0)
{
*ptr++ = a;
total = total + a;
}
}
if(total == i)
printf("%d 是一个完数\n 它的因子是:",i);
* ptr = tep;
while(*ptr++)
printf("%d",*ptr);
}
}
int i,j,sum;
for(i=2;i<1000;i++){
sum=0;
for(j=1;j<=i/2;j++){
if(i%j==0)
sum=sum+j;
}
if(sum==i)
System.out.println(i);
}
public class lianxi09 {
public static void main(String[] args) {
System.out.println("1到1000的完数有: ");
for(int i=1; i<10000; i++) {
int t = 0;
for(int j=1; j<= i/2; j++) {
if(i % j == 0) {
t = t + j;
}
}
if(t == i) {
System.out.print(i + " ");
}
}
}