Re: Integer Solutions
- To: mathgroup at smc.vnet.net
- Subject: [mg6530] Re: [mg6494] Integer Solutions
- From: Robert Pratt <rpratt at math.unc.edu>
- Date: Mon, 31 Mar 1997 23:01:31 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
If all your problems are of the form x1+x2+...+xk=n, xi>0 for all i, then you can use the built-in command Compositions in the standard package DiscreteMath`Combinatorica`. In[1]:= Needs["DiscreteMath`Combinatorica`"] In[2]:= ?Compositions Compositions[n,k] returns a list of all compositions of integer n into k parts. In[3]:= Compositions[3,2] Out[3]= {{0, 3}, {1, 2}, {2, 1}, {3, 0}} Rob Pratt Department of Mathematics The University of North Carolina at Chapel Hill CB# 3250, 331 Phillips Hall Chapel Hill, NC 27599-3250 rpratt at math.unc.edu http://www.math.unc.edu/Grads/rpratt/ On Thu, 27 Mar 1997, Jason Constandinidis wrote: > Does anybody know how mmka can give _ALL_ solutions that are Integers?? > I want for example to solve the equation x+y=3 x>0 y>0 and get > {{3,0}, {2,1}, {1,2}, {0,3}} > Jason. > >