-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem 21.cpp
53 lines (48 loc) · 998 Bytes
/
Problem 21.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//ANSWER IS 31626
#include<iostream>
using namespace std;
int main()
{
int a[10000],i,j=2,k,x,y;
for(int i=0;i<10000;i++)
a[i]=0;
a[220]=1;a[284]=1;
i=2;
while(i<10000)
{
if(a[i]==0)
{
j=0;
k=1;
x=0;
y=1;
while(k<i)
{
if(i%k==0)
j+=k;
k++;
}
while(y<j)
{
if(j%y==0)
x+=y;
y++;
}
if(i==x&&i!=j)
{
a[i]=1;
a[j]=1;
}
}
if(a[i]==1)
cout<<i<<"\n";
i++;
}
long sum=0;
for(i=1;i<10000;i++)
{
if(a[i]==1)
sum+=i;
}
cout<<sum;
}