#4: Partitions of an Integer

Tagged as challenge

Written on 2018-01-30

Similar in spirit to the counting change problem from SICP, write a function to compute the partitions of an integer. A partition of a non-negative integer $N$ is a non-increasing sequence of positive integers less than or equal to $N$ that they sum to $N$.

All of the partitions of $4$ are $(4)$, $(3, 1)$, $(2, 2)$, $(2, 1, 1)$, and $(1, 1, 1, 1)$.

Unless otherwise credited all material copyright © 2010–2018 by Robert Smith