Initial commit
This commit is contained in:
24
problem-45.py
Normal file
24
problem-45.py
Normal 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))
|
||||
|
||||
Reference in New Issue
Block a user