How do I write a a recursive function that counts the number of sequences that sum up to that number (user input)?
kuchick32
-3
Light Poster
Recommended Answers
Jump to PostWhat do you mean "the number of sequences"? Please give an example number and explain what you would expect the result to be. Did you give it a try? You'll get much better replies if you ask a specific question about a problem you're having rather than just asking for …
Jump to PostI think he means for example :
5 = 1 + 1 + 1 + 1 + 1
5 = 1 + 1 + 1 + 2
5 = 1 + 1 + 3
5 = 1 + 4
5 = 5
5 = 4 + 1
5 = …
Jump to PostNo the number 5 has 11 series that adds up to 5, right?
5 = 1 + 1 + 1 + 1 + 1
5 = 1 + 1 + 1 + 2
5 = 1 + 1 + 3
5 = 1 + 4
5 = 5
5 …
Jump to PostAlso, just for giggle, I calculated that this function : 1/2n^2-1/2n+1 gives the number of sequence that sums to a number n. Try it out and see if its correct. I give no guarantees.
All 14 Replies
daviddoria
334
Posting Virtuoso
Featured Poster
kuchick32
-3
Light Poster
mrnutty
761
Senior Poster
mrnutty
761
Senior Poster
mrnutty
761
Senior Poster
darrensmit123
-3
Newbie Poster
WaltP
commented:
Help? There is no help in this post. Just spamming a sig link.
-3
kuchick32
-3
Light Poster
WaltP
commented:
After 36 posts you still can't figure out how to format code properly?
-3
frogboy77
73
Posting Pro in Training
kuchick32
-3
Light Poster
kuchick32
-3
Light Poster
nezachem
616
Practically a Posting Shark
mrnutty
761
Senior Poster
warrentotheG
0
Newbie Poster
frogboy77
73
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.