I want to do this with recursion
If I enter 5
output will be
5=1+1+1+1+1
5=1+1+1+2
5=1+1+3
5=1+2+2
5=2+3
.....
.....
.....
Please give any idea or code.
I want to do this with recursion
If I enter 5
output will be
5=1+1+1+1+1
5=1+1+1+2
5=1+1+3
5=1+2+2
5=2+3
.....
.....
.....
Please give any idea or code.
Last edited by arnabc; 09-07-2007 at 11:20 AM.
What do you have so far?
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd
should the output give
5=1+4
also ??
if not
how did u specify that only those outputs have to be shown??
Write out a few steps
1 is well, just 1
2 is 1 + 1
3 would be
2 + 1
1 + 2
1 + 1 + 1
4 - well, you get the idea.
Once you've got some idea of the pattern, then you can think in terms of what the "n-1" recursive step is going to look like.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.