I was asked this problem years ago at interview for Java developer. It was about using BigInt really, but that's not important. I later slightly extended it and started asking when I interview other people in my turn (usually big-data or data science developers). Curiously, it puzzles about 40% people pretending for several kilo-dollars salary :o
Code could be written in 3 minutes (e.g. in
Python), but then people sometimes stuck for hour. I think most of you, Friends, will solve it easily - but you can check your colleagues for fun. So here it is:
Fibonacci numbers (we all know them) are defined as:
fib = [0, 1, 1, 2, 3, 5, 8, ...] # or in other words fib = 0 fib = 1 # ... fib[n] = fib[n-1] + fib[n-2]
Write the program (usually in Python) which finds index, where Fibonacci value ends with specific digits. For example ending
12345 could be found at fib.
Then find the following:
For which index X fib[X] ends with five digits `55555` ? For which index Y fib[Y] ends with seven digits `7770777` ? For which index Z fib[Z] ends with eight digits `20200123` ?
20200123 is just today's date, nothing special about it. :)
P.S. I think it's ok to drop X, Y, Z in the comments when you find them. Code - as you wish...
P.P.S. if can't solve at once, this problem may give inspiration, though of course you'd better try solving on your own first... If it is necessary I'll update the post with explanation in about three days, though I believe it is too simple for most of readers.