Python BasicsEasy

Find the Nth Term of the Fibonacci Series

Detailed guide and Python implementation for the 'Find the Nth Term of the Fibonacci Series' problem.

Problem Statement

Easy

Write a function fibonacci_nth(n) that takes a positive integer n and returns the nth term of the Fibonacci series (1-indexed). The series is: F(1) = 0, F(2) = 1, F(3) = 1, F(4) = 2, F(5) = 3, ...

Constraints
  • 1 <= n <= 50

Examples

Example 1
Input
n = 5
Output
3
Explanation

The 5th Fibonacci term is 3. The series: 0, 1, 1, 2, 3.

Example 2
Input
n = 1
Output
0
Explanation

The 1st Fibonacci term is 0.

Example 3
Input
n = 10
Output
34
Explanation

The 10th Fibonacci term is 34. The series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.

Need a Hint?
Consider using Basics-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.