-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem_021.c
More file actions
44 lines (36 loc) · 783 Bytes
/
Problem_021.c
File metadata and controls
44 lines (36 loc) · 783 Bytes
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
#include <stdio.h>
long long unsigned sumDivisors(long long unsigned number);
int main(void)
{
long long unsigned counter;
long long unsigned sumCounterA = 0;
long long unsigned sumCounterB = 0;
long long unsigned calculation = 0;
for(counter = 2; counter < 10000; counter++)
{
sumCounterA = sumDivisors(counter);
sumCounterB = sumDivisors(sumCounterA);
if(sumCounterB == counter && counter != sumCounterA)
{
calculation += counter;
}
}
printf("Result: %d", calculation);
}
long long unsigned sumDivisors(long long unsigned number)
{
long long unsigned counter;
long long unsigned sum = 0;
if(number == 2)
{
return 1;
}
for(counter = 1; counter < number; counter++)
{
if(number % counter == 0)
{
sum += counter;
}
}
return sum;
}