blob: 4824b0124ecd4236809d2997210d6b5dbb037b01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#Works, but is rather slow
def Pentagon(n):
return n*((3*n)-1)/2
pentagons = []
for x in range(1,10000):
pentagons.append(Pentagon(x))
count = 1
run = True
while (run):
for x in range(1,count+1):
if pentagons.count(pentagons[count] - pentagons[count-x]) >0 and pentagons.count(pentagons[count] + pentagons[count-x])>0:
print(pentagons[count],"|",pentagons[count - x], "\tDifference D is:", abs(pentagons[count] - pentagons[count-x]))
run = False
#print(pentagons[count] - pentagons[count-x])
count+=1
pentagons.append(Pentagon(count+9998))
|