If one needs to calculate the last digits of a fibonacci number, One can calculate the fibonacci number and then take the last digits. This gets infeasible very quickly.
However, The fibonacci sequence follows a pattern when it comes to the last digits. The last digit repeats every 60 numbers, the last 2 digits repeats every 300 numbers, the last 3 digits repeats every 1500 numbers and so on [Source: https://mathworld.wolfram.com/FibonacciNumber.html].
We can codify this with a program. We can precompute the list and look up the last digits of the number we are interested in.
To run the code,
- Install python3
- Run
python3 last-digits-fibonacci-calculator.py
- Enter the number you wish to compute the digits of