#include <iostream>
usingnamespace std;
int f (int n)
{
if (n == 5)
{
return 0;
}
else
{
return n * n * n + f (n-1);
}
}
int main()
{
cout<<"1^3 + 2^3 + 3^3 + ... + n^3 = \n"<<endl;
cout<<f(20)<<"\n"<<endl;
system("pause");
return 0;
}
Is Calling Statement Of n=50;
Which Mean The Increment By 1, Starting From
2^3 + 3^3 + 4^3+ ... + n^3 and for n = 50
But Base On This Program, My Professor Also Want To Have Similar Recursive, This Time, Instead Of The Increment Of The n Integers. He Want The Program To Be Written Something Like This:
8^2 + 8^3 + 8^4 + ... + 8^n and for n = 30
I Really Lost From Here.
Could Somebody Give Me Some Hint / Helps Base On Program 1 And Applies The Concepts Into The Program 2, Please?
On entering f(n) for the second problem, you need to calculate 8^n.
You'll need a loop to do that.
Then call f(n-1) and add the result.
Does that help?