a = [0, 1, 2] dic = {(2, 1): 1} maxx = 100 from sys import argv if len(argv) > 0: maxx = int(argv[1]) def get(x, y): if y >= x: return a[x] return dic.get((x, y)) for n in xrange(3, maxx + 1): tmp = 0 for i in xrange(1, n): tmp += get(n - i, i) dic.update({(n, i): tmp}) a.append(tmp + 1) print a[-1] - 1