Partition function by ninjalj

int m[9999],*t;p(k,n){t=m+n*99+k;return*t?*t:(*t=k<n?p(k+1,n)+p(k,n-k):k==n);}main(i){for(;i<101;)printf("p(%d)=%d\n",i++,p(1,i));}

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

download

return to the top page