Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Write a Python program to find the nth Fibonacci number.
Answer:

def fibonacci(n):

  if n <= 1:

    return n

  else:

    return fibonacci(n-1) + fibonacci(n-2)

Example:

fibonacci(5)  # Output: 5
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook