CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Fibonacci Recursion

C++ code walkthrough · Question 34
hardRecursion

Code

Read carefully. What does this print?
1#include <iostream>
2using namespace std;
3int fib(int n) {
4 if (n < 2) return n;
5 return fib(n - 1) + fib(n - 2);
6}
7int main() {
8 cout << fib(7) << endl;
9 return 0;
10}

Your answer