Partition function by rolf

m={}
def p(k,n):
 l=k,n
 if k>=n:return k==n
 if l in m:return m[l]
 r=m[l]=p(k+1,n)+p(k,n-k)
 return r
i=1
while i<101:print"p(%d)=%d"%(i,p(1,i));i+=1

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top