Fibonacci sequence

For interviews and fun.

Keno Leon
7 min readOct 6, 2021

--

Even though I write software nearly everyday, I am not much of a mathematician, don’t get me wrong it’s both fascinating and required for many things in code, it’s just when it comes to formulas and formalities most of it goes over my head and requires some effort to understand, so with that out of the way I stumbled upon the Fibonacci Sequence the other day and was immediately fascinated by it, in a gist just imagine that your coding interview tells you to complete the following sequence of numbers and write a script to do so:

55, 89, 144, 233...?

If you’ve been exposed to Fibonacci numbers this will be obvious, but if not the simple trick is that each following number is the sum of the previous two, so 144 is the sum of 55 and 89, if we add 144 + 233 we should get the next number 377 , then you can go on by adding 233 + 377 and so on.

In script form this is one popular ( according to Github Copilot ) way to make a Fibonacci sequence :

Here we populate a Python List via branching conditionals to take care of the early/special cases and then it's just adding the previous 2 indexed list elements, while I'll be using python, you can easily modify it to your language of choice.

After this short introduction you should now be able to sniff a Fibonacci sequence interview question and hopefully answer it, but beyond that the Fibonacci sequence ( or Fibonacci numbers ) are interesting in their own right…

And here are the first 100 Fibonacci Numbers:1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162…

--

--

Keno Leon

AI, Software Developer, Designer : www.k3no.com