![]() |
#2
rjsp2020-10-12 19:32
|
求1000之内的所有完数
#include <iostream>
using namespace std;
int main()
{
cout << "完数有:";
int s = 0;
for (int i = 2; i < 1000; i++)
{
for (int j = 1; j < i; j++)
{
if (i % j == 0)
s += j;
}
if(i == s)
cout << i << " ";
}
cout << endl;
}