BackeasyRecursion

Fibonacci Number Basics Solution

Problem Statement

Given an integer n, calculate the nth Fibonacci number using recursion. The Fibonacci sequence starts with 0 and 1: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1.

Example 1
Input
3
Output
2

Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2.

Constraints

  • 0 <= n <= 30
Live Compiler
Sign InSign Up
Loading...
Test Cases & Output
Click "Run" to execute