Find the sum of last 9 digits of the Fibonacci number .
Note: The first 2 fibonacci numbers are both 1.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Here is a python solution I came up with:
The idea behind it is that
fib
is always a list of two (since that's the only amount of space we need to compute the next value anyway), and it gets updated until the 2016th number is reached. The cheesy one liner at the bottom casts this huge number as a string, chops off all but the last nine digits, then performs a reduce by recasting each individual digit as an integer and summing. Full pass takes about 2ms on average.I'd love to see what else you all come up with!