Amazingly, I had a technical interview yesterday via webex, which featured a question for calculating the nth term of fibs in a curly-bracket language. Being both an ENTERPRISE CUDDER and a long-time prog-rider and who has implemented fibs is a number of both popular and esoteric languages (including some of my own creation), this was an easy task , and I rattled off a solution as follows:
int Fibonacci(int n) { switch(n) { case 0: throw new InvalidFibonacciTermException(); case 1: case 2: return 1; default: return Fibonacci(n-1) + Fibonacci(n-2); } }
Afterwards we discussed that the flaws of this approach, and alternate solutions (where I described a standard iterative solution). I was then probed for a further 90 minutes on various topics.
Today I found out that my application won't be progressing further, and one piece of feedback was that my fibs looked like it had been googled. It seems like my fibs-fu was too strong for these plebs!
>>1 Another guy who doesn't want or need a job and doesn't even try to do what he is asked for in a simple job interview. You all just fail on purpose to post shitty threads about it here.
Name:
Anonymous2020-04-22 18:52
What about n < 0? Either catch all invalid input or don't.
Name:
Anonymous2020-04-22 19:46
Your solution is suspicious. You either memorized or googled it. Or your mental model differs a lot from the ``normal" imperative one.
I thought about it and I still don't understand how it works.
>>7 Not anymore. Your comment made me butthurt enough to learn it.
It's the mathematical definition. It all boils down to that we know the first two result: 1 and 1. The algorithm then breaks down further results into the two we know and adds them up.
In the end you build a fatass tree which is dog slow and memory expensive but very cool.
Name:
Anonymous2020-04-22 22:44
>>8 I was absolutely sure you were trolling. Are you 12?