More of a beginner's question.
You have been given a task to produce all the numbers which add up to
n. Somebody else has had the same problem before.
You will need a method which takes two parameters to start with.
Go through your numbers and decide what you actually want to print out.
If you have 4, 2, how do you get it to print 44, 43, 42, 41, and not 444?
Say, "It should start with two numbers, then adding one number leaves one to go."
"It should continue with one number, then adding one number leaves none to go."
"Then it stops."
Then tell us what you have got. Good luck.
[edit]Added this bit:
When I said "you have been given a task . . ." I ought to have said that what you posted finds all the numbers which add up to
n. I tried it and it works nicely. Have you been through it to see how the recursion and iteration work?[/edit]
[ February 15, 2008: Message edited by: Campbell Ritchie ]