Fibonacci Number Problem

Fibonacci Number Problem — ExecCode School DSA Practice

Solve the Fibonacci Number problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1.

Examples

Input n = 2; Output 1. Input n = 3; Output 2. Input n = 6; Output 8

Constraints

0 <= n <= 30

Practice Fibonacci Number free on ExecCode. Browse DSA problems, topic map, and placement guides.