From: "John D'Errico" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: integer solutions for x_1+x_2+...+x_n = k
Date: Tue, 4 Nov 2008 21:31:04 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 28
Message-ID: <geqeuo$m4e$>
References: <geku21$eku$> <gel0b6$3li$> <geqe85$chp$>
Reply-To: "John D'Errico" <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1225834264 22670 (4 Nov 2008 21:31:04 GMT)
NNTP-Posting-Date: Tue, 4 Nov 2008 21:31:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: comp.soft-sys.matlab:498955

"Oriole " <> wrote in message <geqe85$chp$>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gel0b6$3li$>...
> > 
> > Have you check the number of solutions for large n? It might be not possible to compute.
> > 
> > Here is code in FEX  that can accomplish that, but again, try to look at the feasibility before solving:
> > 
> > Bruno
> Hi, Bruno,
> Thank you for the help. Your subfunction v=allVL1eq(n, L1, head) works fine for my problem. But I have some difficulty in understanding the recursive algorithm.  I know it does the job, and more or less how it works, but still feel confused about it.  What is the basic idea of this recursive algorithm? would you like to explain a litle bit for me...  Lots of thanks
> /Oriole

You can look at my partitions function on the
file exchange. It is certainly less elegant than
Bruno's code as I recall, although it is still

The idea behind these recursive methods to find
the partitions of the number k is to pick a value
for x1. Once you have done that, you are now
looking for all the partitions of k-x1. Repeat
recursively until done.