Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

fib

Write a function fib that takes in a number argument, n, and returns the n-th number of the Fibonacci sequence.

The 0-th number of the sequence is 0.

The 1-st number of the sequence is 1.

To generate further numbers of the sequence, calculate the sum of previous two numbers.

fib(0); # -> 0
fib(1); # -> 1
fib(2); # -> 1
fib(3); # -> 2
fib(4); # -> 3
fib(5); # -> 5
fib(35); # -> 9227465
fib(46); # -> 1836311903