Is there any Algorithm to Write a Number $N$ as a Sum of $M$ Natural Numbers? I have a number $N$ (for example $N=64$). 
Is there any algorithm to find all the feasible ways for writing the number $N$ as a sum of $M$ positive numbers? 
(For example $M=16$) --- Repetition is allowed.

$n_1 + n_2 + n_3 + ... + n_{16} = 64$
      $n_i \ge 1$


This is the stars and bars problem.  Imagine a line of $64$ stars and $63$ candidate bars between them.  Pick $15$ of those bars to be real and read off the groupings.  There are ${64 \choose 15}=122131734269895$ To make the list, there are many algorithms on the web to generate the combinations of $15$ choices out of $63$.  For example, you can use the fact that ${63 \choose 15}={62 \choose 14}+{62 \choose 15}$, where the first are combinations that include the first bar (and hence have $1$ as the first summand) and the second are those that do not have the first bar (so the first summand is greater than $1$).  This suggests a recursive algorithm.
