def p44(): n = 2500 pent = pentagonal_n(1, n, 'dict') pentSet = pentagonal_n(1, n, 'set') print 'starting loop..' for j in range(1, n): for k in range(j, n): if pent[k] - pent[j] in pentSet and pent[k] + pent[j] in pentSet: print k, j, pent[k], pent[j] return pent[k] - pent[j]
def p45(): n = 100000 t = triangular_n(1, n) p = pentagonal_n(1, n) h = hexagonal_n(1, n) return set.intersection(t, p, h)