solulubeta
Sign in
Recursion & Memo / See it, then write it
01.11 · Problem

Fibonacci Number

Easy Two smaller calls Pro

Fibonacci numbers start 0, 1, and each next one is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, … Return fib(n). Write it as plain recursion. It gets slow near n = 30, and chapter 3 shows why.

Examples

Example 1

Input:  n = 2
Output: 1

Example 2

Input:  n = 10
Output: 55
solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 10 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 11 of 44 · updated 2026-10-13