def main(): pents = [n for n in geometry.pent_numbers(10000)] for j in xrange(len(pents) - 1): for k in xrange(j + 1, len(pents)): psum = pents[j] + pents[k] pdiff = pents[k] - pents[j] if utils.list_has(pents, psum) and utils.list_has(pents, pdiff): print abs(pdiff) print (pents[j], pents[k], psum, pdiff)
def main(): # tris = [n for n in geometry.triangle_numbers(50000)] pents = [n for n in geometry.pent_numbers(50000)] hexs = [n for n in geometry.hex_numbers(50000)] for tri_n in geometry.triangle_numbers(): if utils.list_has(pents, tri_n) and utils.list_has(hexs, tri_n): # fast binary-search # if tri_n in pents and tri_n in hexs: # old slow approach if tri_n > 40755: print tri_n break
def main(n): pairs = [] for a in xrange(n): b = amicable(a) if bool(b) and a < n and b < n: # print a, b if utils.list_has(pairs, a) or utils.list_has(pairs, b): None else: pairs.append(a) pairs.append(b) print sum(pairs)
def main(): total = 0 abundants = make_abundants() sums = make_abundant_sums(abundants) sums = list(sums) sums.sort() # print len(sums) # sums.sort() # print 'sorted sums' for x in xrange(0, 28123): if not utils.list_has(sums, x): # print x total += x # for x in xrange(1, 28124): # for a in abundants: # if a < x: # x2 = x - a # if utils.list_has(abundants, x2): # break # else: # total += x # break print total