Failed fibonacci question

probably you just suck at interviews. good news is that you can practice that.

the first thing out of your mouth should be

>"Sure"

then you if you know what you're doing you ask a bunch of questions to make sure what you have in mind is actually what they want.

if you don't know what you're doing you can say shit like

>It's been a while, the Fibonacci sequence was one of those increasing integer sequences, right? It goes like 1, 2, 4, 6..

then they usually stop you and say shit like

> na, 1, 1, 2, 3, 5

and then you say

>"ah, I remember, the pattern is you add this and the previous number to get the next one, right?"

at which stage did you fail?

You will instantly fail if you don't know how to write a recursive loop. That's why it's an interview question. It's not the type of thing someone will generally arrive at on their own without knowing about it already.

recursive fibonacci is dumb, unless you have to print a reverse sequence, then maybe. still dumb.

but yeah, I assumed OP just blanked, seeing how he has a degree in CS.

>It's babbys first recursive loop
Fib is rather inefficient and very slow as recursion

here's a matrix you can multiply 4 fibonacci numbers by to get the next 4
what's cool is the elements are powers of two, so you can bit shift

forgot the actual link:
wolframalpha.com/input/?i=[[4,4,1,0],[1,4,2,0],[2,1,0,0],[1,1,0,0]] * [[3],[2],[1],[1]]

I failed immediately basically. I blanked out and had no idea what parameters to take or how to start the function at all.

All i could say was i know its solved recursively and i said a base case is needed and the final statement would be the recursive call.

They gave me clues and advice but i just couldn't figure out how to start it.

Fuck...

did you ask them to remind you what the fibonacci series was? dont be afraid to ask so you can prove the knowledge you have

Which is why you should consider things like caching or just using maths where possible to make it better, which is what I was pointing at in the last part of the post.

With caching you cut down from like 13,000~ moves to just 37 for fib(20), while keeping the super clean code that recursion gives

Yeah pretty much. I failed nothing at uni and graduated at 22 playing league of legends most of the day, was an addict. Did the bare minimum before exams and assignments.

I felt incredibly stupid trying to solve it. I couldnt start it at all and i had no idea how to set up a function/data members to print the fib sequence. They gave me plenty of clues but i just couldnt think of a solution on the spot.

Starting to think i might not be cut out for programming but I'm going to study a lot and again if/when i get another interview.