$$p(n) = \sum_{k \ge 1} (-1)^{k+1}\left[
p(n - k(3k-1)/2) + p(n - k(3k+1)/2)\right],$$
which needs \(O(\sqrt n)\) terms per value rather than \(O(n)\).
Usage
morie_partition_count(n, distinct = FALSE, odd_only = FALSE)
Arguments
- n
Non-negative whole number.
- distinct
Count partitions into distinct parts.
- odd_only
Count partitions into odd parts.
Details
distinct counts partitions into distinct parts and odd_only into
odd parts. Euler's theorem says those two counts are EQUAL at every
\(n\), which the parity test checks rather than assumes.
References
Andrews GE (1976), The Theory of Partitions.
Examples
morie_partition_count(n = 5L)
#> 7