I would like to know if there is a generic way to write a number N as a sum of K integers. The integer can be 0, 1, 2...N. For example, 3 expressed as a sum of 2 numbers can be {0,3} {3,0} {1,2} {2,1} , thank you.
Asked
Active
Viewed 76 times
0
-
2Look up stars and bars combinatorics, – true blue anil Nov 22 '22 at 06:52
-
The general answer, when counting different permutations as you do, is $(N+1)^{k-1}$. From the "stars and bars" idea, you have to place $k-1$ bars, and you can place them between any of the $N$ stars, as well as at the ends. – SomeCallMeTim Nov 22 '22 at 09:23
-
See Number of nonnegative integral solutions of $x_1 + x_2 + x_3 + \cdots + x_m = k$. – N. F. Taussig Nov 22 '22 at 09:29