Initial commit

This commit is contained in:
Kevin Keogh
2018-07-02 15:45:49 -04:00
parent 60b3954a3b
commit fd817f8811
28 changed files with 809 additions and 0 deletions

24
problem-45.py Normal file
View File

@@ -0,0 +1,24 @@
import itertools
SAMPLES = 100000
def triangle_num(n):
return n * (n+1) / 2
def pentagonal_num(n):
return n * (3 * n -1) / 2
def hexagonal_num(n):
return n * (2 * n - 1)
if __name__ == '__main__':
tris = [triangle_num(x) for x in range(2, SAMPLES)]
pents = [pentagonal_num(x) for x in range(2, SAMPLES)]
hexs = [hexagonal_num(x) for x in range(2, SAMPLES)]
triplets = itertools.product(tris, pents, hexs)
print(set(tris) & set(pents) & set(hexs))