Integer Partition

Ko Sv's icon

hi guys,
need a little bit help with that.
this is what i'm trying to recreate:
https://en.wikipedia.org/wiki/Partition_(number_theory)
(there is a bug with the parenthesis linking above. )
and here is a python implementation:
https://stackoverflow.com/questions/2065553/get-all-numbers-that-add-up-to-a-number


so essentially i'm trying to get all partitions from a number :

3->
3
2 1
1 1 1

4 ->
4
3 1
2 2
2 1 1
1 1 1 1

etc..

any help would be.. ahm, yeah.. very helpful! :)
cheers!

Roman Thilenius's icon

https://oeis.org/A000041 also offers some quasi-code, but i dont understand it.

Andrew's icon

Just port the python to javascript, an ideal way to learn some js. ;)

Roman Thilenius's icon

btw, in 32-bit max you can not go much higher than n=100 anyway.

https://oeis.org/A000041/list

anyone finds a list longer than that?

andrea agostini's icon

If you feel like installing the bach package, you can use bach.partition.
Hope this helps,
aa

Ko Sv's icon

@ANDREA nice, very nice! thanks