Challenge 5: Compute nth Fibonacci Number

In this challenge, you are required to compute the nth Fibonacci number.

Problem Statement

Implement the Fibonacci function that takes a number n and calculates the nth Fibonacci.

The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … The next number is found by adding up the previous two consecutive numbers.


An integer


nth fibonacci term

Sample Input


Sample Output


Coding Exercise

Write your code in the code widget below. If you don’t get it right, don’t fret; the solution is also given.

Get hands-on with 1000+ tech skills courses.