Solution: Huge Fibonacci Number

Solution for the Huge Fibonacci Number Problem.

We'll cover the following...

Solution

In this problem, nn might be so huge that an algorithm looping for nn iterations will be too slow. Therefore, we need to avoid such a loop. To get an idea of how to solve this problem without going through all Fibonacci numbers FiF_i for ii from 00 to nn, take a look at the table below:

Stop and think: Do you see any interesting properties of the last two rows in the table above?

Both these sequences are periodic! For m=2m = 2 ...