ProgrammingVery hard

With fib(1) = fib(2) = 1, what is the largest n for which fib(n) fits in a signed 64-bit long long?

  1. A. 92
  2. B. 46
  3. C. 78
  4. D. 93

Correct answer: A. 92

fib(92) = 7540113804746346429 is below LLONG_MAX = 2^63 - 1, but fib(93) is about 1.22 x 10^19 and overflows. 93 is the limit for unsigned 64-bit, 46 for a signed 32-bit int, and 78 the last value a double holds exactly (below 2^53).

More C Programming questions

Exams that ask this topic