作者:yunjinqi 类别:
日期:2023-05-29 16:01:42
阅读:427 次 消耗积分:0 分
#include <stdio.h>
int is_perfect_num(int num){
int sum=0;
int i;
for (i=1;i<num;i++){
if (num%i==0){sum+=i;}
}
if (sum==num){return 1;}
return 0;
}
int main(){
int m,n;
int t,i,j;
int count=0;
if (scanf("%d",&m)!=EOF && scanf("%d",&n)!=EOF){
for (i=m;i<=n;i++){
t = is_perfect_num(i);
//printf("%d %d\n",i,t);
if (t==1){
count++;
//输出具体的信息
printf("%d = 1",i);
for (j=2;j<i;j++){
if (i%j==0){printf(" + %d",j);}
}
printf("\n");
}
}
if (count==0){printf("None");}
}else{
printf("int m and n occur something wrong");
}
return 0;
}