- 注意真因子的求法。以及最小完数是6,所以从6开始。
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin>>n){
int count = 0;
for(int i = 6; i<=n;i++){
int temp = 0;
for(int j = 1; j<i;j++){
if(i%j==0){//找到自己的真因子(从一开始算)
temp+= j;
}
}
if(temp==i){//如果是完数
count++;
}
}
cout<<count<<endl;
}
return 0;
}
京公网安备 11010502036488号