I\'m having a hard time understanding why
#include using namespace std; int fib(int x) { if (x == 1) { return 1; } else {
Why not use iterative algorithm?
int fib(int n) { int a = 1, b = 1; for (int i = 3; i <= n; i++) { int c = a + b; a = b; b = c; } return b; }