Hello Amin The partitions library does this.
If N=4 and k=3: > library(partitions) > blockparts(rep(4,3),4) [1,] 4 3 2 1 0 3 2 1 0 2 1 0 1 0 0 [2,] 0 1 2 3 4 0 1 2 3 0 1 2 0 1 0 [3,] 0 0 0 0 0 1 1 1 1 2 2 2 3 3 4 > The solutions are enumerated in the columns. HTH rksh On 19 Nov 2007, at 09:57, [EMAIL PROTECTED] wrote: > Dear all, > Is there any method in R to find all possible nonnegative integer > solutions to the linear equation with unit coefficients as follow: > X1+X2+...+Xk=N > Thank you, > Amin Zollanvari > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.