Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 1.02 KB

Fibonacci-kata.md

File metadata and controls

30 lines (21 loc) · 1.02 KB

Fibonacci kata

https://www.codewars.com/kata/fibonacci-number

Fibonacci number (Fibonacci sequence), named after mathematician Fibonacci, is a sequence of numbers that looks like this:

0, 1, 1, 2, 3, 5, 8, 11,...

You get first two starting numbers, 0 and 1, and the next number in the sequence is always the sum of the previous two numbers. Fibonacci introduced it in 1202, in his book Liber Abaci, using it to calculate the growth of rabbit populations.

So what will be your task? You should write a function fib, that takes one parameter steps, and returns a number from the Fibonacci sequence, based on the parameter steps, which determines the position in Fibonacci number.

For example fib(0) returns 0, fib(4) returns 3, fib(15) returns 610.

Online calculator: http://php.bubble.ro/fibonacci/

Expected behaviour

Input   |   Output
0           0
1           1
2           1
3           2
4           3
5           5
6           8
7           13
15          610