#385 · Math · Advanced · 140 XP · about 25 min
The Fibonacci numbers start F(0) = 0 and F(1) = 1, and each one after that is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, ...
Write fib_mod(n) that returns F(n) modulo 1,000,000,007, that is F(n) % 1_000_000_007.
fib_mod(10) # returns 55 fib_mod(0) # returns 0 fib_mod(50) # returns 586268941
F(50) is 12,586,269,025, and 12,586,269,025 % 1,000,000,007 is 586,268,941.
First solves only, ranked by stars and then time.