完数
# include "stdio.h" int main(int argc, char* argv[]) { int i,j,s; int count; count=0; for(i=2;i<=1000;i++) { s=0; for(j=1;j<i;j++) { if(i%j==0) { s=s+j; } } if(i==s) { printf("%d ",i); count++; } } printf("完数一共有%d个",count); return 0; }
# include "stdio.h" int main(int argc, char* argv[]) { int i,j,s; int count; count=0; for(i=2;i<=1000;i++) { s=0; for(j=1;j<i;j++) { if(i%j==0) { s=s+j; } } if(i==s) { printf("%d ",i); count++; } } printf("完数一共有%d个",count); return 0; }