-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler_problem21.py
56 lines (40 loc) · 1.04 KB
/
euler_problem21.py
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
54
55
56
#!/usr/bin/python
#Filename: euler_problem21.py
#variables used(n, s, p, i, x,)
numbs = { }
##numbs represents all of the factors of a particular input
sums = { }
##sums represents the sum of all of the factors for a particular input
n = [ ]
s = 284
for p in range(1,10001):
hello = [ ]
for i in range(1,p):
if p % i == 0:
hello.append(i)
numbs[p] = hello
#sums = sum(numbs[p])
#print(sums)
##for i in numbs:
## print(i, numbs[i])
for i in numbs:
sums[i] = sum(numbs[i])
##for i in sums:
## print(i,':', sums[i])
compare = [ ]
numbers = [ ]
for z in range(1,10001):
for x in range(1,10001):
if z == sums[x]:
if x == sums[z]:
if x == z:
q = 0
else:
zoo = (x,z)
paul = (x+z)
numbers.append(zoo)
compare.append(paul)
j = sum(compare)
b = j/2
print('the amicable pairs are', numbers)
print('the sum of the amicable pairs is', b)