An ordered list of tuples whose elements sum to $n$ I am trying to find an method for creating an ordered list of tuples whose elements sum to $n$.
For instance if $n=15$, then the list should include the tuple
$(5,5,5)$ because $5+5+5=15$, $(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)$ because $1+1+1+1+1+1+1+1+1+1+1+1+1+1+1=15$, and $(12,1,2)$ because $12+1+2=15$.   
Order matters, so $(1,14)$ and $(14,1)$ are both elements of the list.
Also, $0$ is not an element of any tuple.

This is what I have so far:
I can list the tuples in order of $k$-ary. 
$1$-ary tuples:
$(n)$
$2$-ary tuples: $((n-1),1), (1,(n-1)), ((n-2),2), (2,(n-2)) ... ((n-n/2), n/2), (n/2,(n-n/2))$
What should go here? What is the rule for every $k$-ary where $k\lt n$? 
$n$-ary tuples:
$(1,1,1,...,1)$ 
 A: A suggestion: We assume $0$ is not allowed. Then there are $2^{n-1}$ such tuples. By the way, such a tuple is called a composition of $m$.  
We can think of $n$ as a a sum of $n$ $1$'s. Write down a list of $n$ $1$'s, with a bit of space between them, like this:
$$1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1\qquad 1$$
There are $n-1$ gaps between these $1$'s. Any choice of a subset of these gaps will give us a composition of $n$. 
There is a natural correspondence between the numbers $0$ to $2^{n-1}-1$, written in binary notation, and the subsets of the set of gaps. That will give you an explicit listing of the compositions. 
Added: I kind of regret writing down $1$'s, it should have been $X$'s. Then we can put a $1$ into a gap, or a $0$. That gives us an $n-1$-bit binary number that uniquely identifies the composition. 
Another way: We can write a recursive program. To list all the compositions of $n+1$, note that they are of $2$ types: (i) the ones that begin with $1$ and (ii) the ones that begin with a number $2$ or greater.
To list the ones that begin with $1$, call on the program to list the compositions of $n$, and prepend a $1$ to each. To list the ones that begin with $2$ or more, call on the program to list the compositions of $n$, and add $1$ to the first term of each.
A: Here is an algorithm to print all combinations:
def PrintRec(n,L):
    if n=0:
        print(L)
    for i =1 to n:        
        L' = L appended by i 
        PrintRec(n-i,L')

def PrintAll(n):
    PrintRec(n,EMPTY_LIST)

PrintAll(n)

Here is a short Python program that works according to the same idea(here I replace a list with a string):
def PrintRec(n,str):
    if n==0:
        print(str+"\n")
    for i in range(1,(n+1)):        
        PrintRec(n-i,str+" "+repr(i))

def PrintAll(n):
    PrintRec(n,"")

PrintAll(3)

You can change 3 to your desired number.
