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$


function partitionCombination(N,m,p) {
    if (N == 0) print(p);
    else {
      L = p.length;
      for (i = m; i >= 1; i--) {
        p[L] = i;
        partitionCombination(N-i,i,p);
      }
      p.length = L;
    } 
}

 function partitionOrderCounts(N,p) {
    if (N == 0) print(p);
    else {
      L = p.length;
      for (i = N; i >= 1; i--) {
        p[L] = i;
        partitionOrderCounts(N-i,p);
      }
      p.length = L;
    } 
}
partitionCombination(8,8,[]);
partitionOrderCounts(8,[]);

