#include<stdio.h>void isperfect(int a);int sumofprime(int b); int main() { int n,m,i; printf("please input n:"); scanf("%d",&n); isperfect(n); return 0; } void isperfect(int n) { int i,sum;//n is you number sum=sumofprime(n); if(n==sum) printf("this number is a perfect number\n"); else printf("this number is not a perfect number\n"); } int sumofprime(int b) { int flag,sum=0,n; for(n=1;n<b&&flag;n++) { if(n%b==0); { flag=0;sum+=n; } } return sum; }总是输出this number is not a perfect number(完美数定义是小于这个数的质数之和恰好等于这个数,例如3=3)
添加回答
举报
0/150
提交
取消