Computing p(n), the number of partitions of n

This is a BCMATH version of the BC program partition, which in turn is based on a BASIC program, which depends on Euler's recurrence relation

For example:

p(1)-p(0)= 0, p(1) = 1
p(2)-p(1)-p(0)= 0, p(2) = 2
p(3)-p(2)-p(1)= 0, p(3) = 3
p(4)-p(3)-p(2)= 0, p(4) = 5
p(5)-p(4)-p(3)+p(0)= 0, p(5) = 7
p(6)-p(5)-p(4)+p(1)= 0, p(6) = 11
p(7)-p(6)-p(5)+p(2)+p(0)= 0, p(7) = 15
p(8)-p(7)-p(6)+p(3)+p(1)= 0, p(8) = 22
p(9)-p(8)-p(7)+p(4)+p(2)= 0, p(9) = 30
p(10)-p(9)-p(8)+p(5)+p(3)= 0, p(10) = 42

See Hardy and Wright An introduction to the theory of numbers (1962 edition), p. 286 or Harald Scheid, Zahlentheorie, 2. Auflage, s. 387.
Also see a lecture by Ken Ono.

Enter n (1 ≤ n ≤ 10000):

Last modified 23rd June 2011
Return to main page