Example 2: The Fibonacci Series

Recursively calculate the Fibonacci series.

We'll cover the following

What is the Fibonacci sequence?

The Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones, starting from 0 and 1. Mathematically:

F0=0,F1=1F_{0}= 0, F_{1} = 1
For n>1:n>1:
Fn=Fn1+Fn2F_{n}= F_{n-1} + F_{n-2}

The beginning of the sequence is thus: 0,1,1,2,3,5,8,13,21,34,55,89,...0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Let’s design a recursive approach to calculate the nth term of the Fibonacci sequence.

Get hands-on with 1400+ tech skills courses.