Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Let P(n, k, m) be the number of possibilities to write n as a sum of k summands, with all summands being in the range [1, m]
- If the order matters (so P(3,2,2) = 2, since 1+2 = 3 and 2+1 = 3)
- P(n, 1, m) = 1 when m >= n
- P(n, 1, m) = 0 otherwise
- P(n, k, m) = sum from i=1 to m: P(n - i, k - 1, m)
- If the order doesn't matter (so P(3,2,2) = 1, since 1+2 = 3)
- P(n, 1, m) = 1 when m >= n
- P(n, 1, m) = 0 otherwise
- P(n, k, m) = sum from i=1 to m: P(n - i, k - 1, i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement