Partition function by jamesaxl

def p(n):\x0d
 L=[[1]]\x0d
 for i in range(1,n+1):\x0d
  L.append([L[x][0] for x in range(i - 1, -1, -1)])\x0d
  for j in range((i + 2)/2, i):\x0d
   L[j][0] = L[j].pop(0) + L[j][0]\x0d
 return sum(L[n])\x0d
i=0;exec("i+=1;print'p(%d)=%d'%(i,p(i))\n")*100

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

download

return to the top page