Coding a Fibonacci Sequence Function

Question

A Fibonacci sequence is a set of numbers such that the number N is the sum of N-1 and N-2, starting from 0 (N = 0) and 1 (N = 1). The sequence is written as 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, etc. Given N, write a function that returns the n-th Fibonacci number.

For example:

N = 2, return 1
N = 4, return 3
N = 6, return 8

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now