How do I write a recursive function to compute (3^2)+(3^3)+(3^4).......+(3^n) ?
DS9596
0
Junior Poster in Training
Recommended Answers
Jump to PostWhat have you done, besides posting your homework assignment?Show your code to us and pinpoint the errors you have.We will be more than happy to help. :)
Jump to PostWell said ddanbe.
Here the principle of recursive function :
Technically, a recursive function is a function that makes a call to itself. To prevent infinite recursion, you need to know the stop condition.Here in your case the stop condition should be n == 1. and you should care …
Jump to PostAn other hint?
What could the function prototype look like?
int sumToN( const int nSum, const int nTerm, const int N );
What would the tail recursive call look like?
How would you call the the function?
(What initial values ?)
All 9 Replies
ddanbe
2,724
Professional Procrastinator
Featured Poster
helmi_1
0
Newbie Poster
David W
131
Practically a Posting Shark
DS9596
0
Junior Poster in Training
DS9596
0
Junior Poster in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
DS9596
0
Junior Poster in Training
NathanOliver
429
Veteran Poster
Featured Poster
David W
131
Practically a Posting Shark
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.