DEV Community

Discussion on: School problem from senior developer interview

Collapse
 
arseniyk profile image
Arseniy Krasnov • Edited

There a trick you can use:

last 2 and 3 digits of fibonacci repeats each 1500 terms
last 4 digits repeats each 15,000
last 5 digits repeats each 150,000
last 6 digits repeats each 1,500,000
last 7 digits repeats each 15,000,000

x = 92.740
y = 4.562.603
z = 280.555.264

Collapse
 
rodiongork profile image
Rodion Gorkovenko

Nice idea about finding "the loop length" after which "endings" repeat :) Perhaps some other puzzle could be invented from it.

However my approach was simpler - just taking modulo by 10eX where X is amount of digits in the number we seek. Then numbers won't grow longer than this.

I suspect your and mine approaches are really two versions of the same fact, however