Skip to content

Commit

Permalink
Add a list-cached version of problem 044 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt authored Oct 3, 2021
1 parent 53167c7 commit 032d165
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions euler0XX/euler044-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from itertools import count
from math import sqrt

def is_pentagonal(number):
n = (1 + sqrt(1 + 24 * number)) / 6
return n.is_integer()

prev = []
for i in count(1):
pk = i * (3 * i - 1) // 2

for pj in prev:
if is_pentagonal(pk + pj) and is_pentagonal(pk - pj):
print(pk - pj)
break

else:
prev.append(pk)
continue

break

0 comments on commit 032d165

Please sign in to comment.