Question 41
Consider the following function:
int f(int n) {
static int r = 0;
if (n <= 0) return 1;
if (n > 3) {
r = n;
return f(n - 2) + 2;
}
return f(n - 1) + r;
}What is the value of f(5)?
Sign in to see the answer
Answers and explanations are free — they just need an account.