import euler n = 61 pent_nums = [] cache = {} while True: if euler.p(n, pent_nums, cache) % 1000000 == 0: break n += 1 print n
= 2 + 2 + 1 + 1 = 2 + 1 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1 + 1 7 = 7 = 6 + 1 = 5 + 2 = 5 + 1 + 1 = 4 + 3 = 4 + 2 + 1 = 4 + 1 + 1 + 1 = 3 + 3 + 1 = 3 + 2 + 2 = 3 + 2 + 1 + 1 = 3 + 1 + 1 + 1 + 1 = 2 + 2 + 2 + 1 = 2 + 2 + 1 + 1 + 1 = 2 + 1 + 1 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1 + 1 + 1 ''' from euler import partition as p assert 7 == p(5) assert 56 == p(11) assert 190569291 == p(100)-1 # excluding itself (1-partition) print p(100)-1
= 3 + 1 + 1 + 1 = 2 + 2 + 2 = 2 + 2 + 1 + 1 = 2 + 1 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1 + 1 7 = 7 = 6 + 1 = 5 + 2 = 5 + 1 + 1 = 4 + 3 = 4 + 2 + 1 = 4 + 1 + 1 + 1 = 3 + 3 + 1 = 3 + 2 + 2 = 3 + 2 + 1 + 1 = 3 + 1 + 1 + 1 + 1 = 2 + 2 + 2 + 1 = 2 + 2 + 1 + 1 + 1 = 2 + 1 + 1 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1 + 1 + 1 ''' from euler import partition as p assert 7 == p(5) assert 56 == p(11) assert 190569291 == p(100) - 1 # excluding itself (1-partition) print p(100) - 1
''' This problem is a variant of P0076 ''' from euler import partition as p n = 0 while True: n += 1 pn = p(n) if pn%1000000==0: break print n, pn