Computer Science EngineeringVery hard

Consider int f(int n){ if(n<=1) return 1; return f(n-1)+f(n-2); }. What does f(6) return?

  1. A. 8
  2. B. 13
  3. C. 21
  4. D. 10

Correct answer: B. 13

With f(0)=f(1)=1 the values run 1,1,2,3,5,8,13, so f(6)=13.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic