Skip to content
loading...

School problem from senior developer interview

Rodion Gorkovenko on January 22, 2020

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 ex... [Read Full]
markdown guide
 

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

 

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

 

That was a fun task and I could refresh some aspects of python doing it. Thanks!

Until now (programm is still executing) I just have the following solution:
X -> 92740
Y -> ???
Z -> ???

I am pretty sure that my solution is far from perfect, since it has a huge runtime and memory consumption. Therefore I'm really looking forward to a better approach.

 

Jannik, Hi!

Thanks for attempt!

Yep, it is just a matter of making it work without speed degradation due to number length increase :)

 

Hi,

so far I have
x - 92.740
y - 4.562.603

Have a nice weekend
Michael

 

Michael, Hi!

Thanks for try! Judging by "so far" it seems you also use straightforward implementation which becomes a bit slower as the values grew :)

Good luck!

 

Hi Rodion,

yes, I started with a default-Fibonacci, and that take a lot of time ;O)

With a little optimization (using only the necessary decimal places), the last value can be found within minutes.

b: 54212345 idx 155
b: 77255555 idx 92740
b: 67770777 idx 4562603
b: 20200123 idx 145555264

So I found z - 145.555.264

Is that correct?

Hi Michael!

At least my results are exactly the same! So I believe you are right and this is correct :)

code of conduct - report abuse