The Fibonacci sequence is a popular series of numbers in mathematics, where every number is the sum of the two numbers before it. The first two terms in the series are 0 and 1:
0 1 1 2 3 5 8 13
Let’s write a function which takes in a number, n, and returns the nth number in the Fibonacci sequence. It is important to note that for the following example, we will be treating all inputs less than 1 as incorrect and therefore, our input will start from 1. So, if n == 6, the function will return 5: