C++ Practice Questions – Calculate Function Value

C++ Practice Questions - Calculate Function Value

Time Limit: 2s Memory Limit: 192MBProblem DescriptionCalculate the function value according to the following recursive formula.When x=1, f(x)=10; when x>1, f(x)=f(x-1)+2Input FormatInteger variable xOutput Formatf(x)Sample Input10Sample Output28Code(1) Recursive Version #include <iostream> using namespace std; int f(int x) { if (x == 1) { return 10; } else { return f(x – 1) + 2; }} … Read more