Looking to return a list of all ways of choosing N non-negative integers so that they sum to M
For instance if N = 3 and M = 2 this would return
[[1]]
[1] 0 0 2
[[2]]
[1] 0 1 1
[[3]]
[1] 0 2 0
[[4]]
[1] 1 0 1
[[5]]
[1] 1 1 0
[[6]]
[1] 2 0 0
Looking to return a list of all ways of choosing N non-negative integers so that they sum to M
For instance if N = 3 and M = 2 this would return
[[1]]
[1] 0 0 2
[[2]]
[1] 0 1 1
[[3]]
[1] 0 2 0
[[4]]
[1] 1 0 1
[[5]]
[1] 1 1 0
[[6]]
[1] 2 0 0