Dsa
Recursion
Easy
Calculate Fibonacci Sequence
Write a program to calculate the nth Fibonacci number. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. Input an integer n and output the nth Fibonacci number.
Example:
Input:
6
Output:
8
Key concepts
recursiondynamic programmingmathematics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now