この表現は call partitionです。さまざまな方法で解決できます。
たとえば、
f(x, m) - number of partitions of x
such that the largest number in that partition is m
それから
f(x, m) = sum of all f(x - m, k) where (1 <= k <= m),
also (k<=x-m), because f(x, y) = 0 where (y > x)
あなたの例では(パーティションの数自体も数えましょう(f(x、x)= 1))
f(1, 1) = 1
f(2, 1) = f(1, 1) = 1
f(2, 2) = 1
f(3, 1) = f(2, 1) = 1
f(3, 2) = f(1, 1) = 1 //+ f(1, 2) zero
f(4, 1) = f(3, 1) = 1
f(4, 2) = f(2, 1) + f(2, 2) = 2
f(4, 3) = f(1, 1) = 1 // + f(1, 2) + f(1, 3) zeroes
f(4, 4) = 1
したがって、f(4, 1)、f(4, 2)、f(4, 3)、f(4, 4) = 5 の合計 (4 自体をパーティションと見なさない場合は 4)