Competitive ProgrammingEasy

Fibonacci Numbers

Detailed guide and Python implementation for the 'Fibonacci Numbers' problem.

Problem Statement

Easy

Write a function nth_fibonacci(n) that returns the nth Fibonacci number. Assume F(0) = 0 and F(1) = 1.

Constraints
  • 0 <= n <= 100

Examples

Example 1
Input
nth_fibonacci(9)
Output
34
Explanation

F(9) is computed as F(8) + F(7) = 21 + 13 = 34.

Example 2
Input
nth_fibonacci(0)
Output
0
Explanation

F(0) is 0.

Need a Hint?
Consider using Dynamic Programming-specific data structures like sets or heaps.
Edge Cases to Watch
  • Empty input structures
  • Single element inputs
  • Large numerical bounds

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.