## Archive for February, 2016

## Fun with Fibonacci

Or, how to annihilate an interview question. I was asked this a little over a year ago in an interview, and I’d been asked it a few times before then too; it’s pretty common.

“Write a function that takes a parameter n and returns the nth Fibonacci number.” The Fibonacci sequence, if you don’t already know, is defined like this: f(1) and f(2) are both 1. After that, each number in the sequence is the sum of the previous two, so, f(3) is 2 (because 1+1), then f(4) is 3, then f(5) is 5, and so on.