Data Structures & AlgorithmsModerateICPC regional · Codeforces Div2 B

Problem: Compute the 50th Fibonacci number F(50) with F(1) = F(2) = 1, modulo 1,000,000,007.

  1. A. 586268941
  2. B. 778742000
  3. C. 365010934
  4. D. 586269025

Correct answer: A. 586268941

F(50) = 12586269025, and iterating with a reduction mod 1,000,000,007 at every step gives 586268941. An off-by-one index gives F(49) → 778742000 or F(51) → 365010934, and reducing mod 10⁹ instead of 10⁹ + 7 gives 586269025.

More Coding Interview Problems questions

Exams that ask this topic