In [1]:
from math import sqrt
import time
start = time.time()
inv_h = lambda h: (1 + sqrt(1+8*h))/4
inv_p = lambda p: (1 + sqrt(1+24*p))/6
inv_t = lambda t: (-1 + sqrt(1+8*t))/2
N = 144
while True:
N += 1
hex = N*(2*N-1)
if inv_t(hex).is_integer() and inv_p(hex).is_integer():
print "Answer:" + str(hex)
break
print "Elapsed time:{0} seconds".format(time.time()-start)
In [9]:
In [9]:
In [ ]: