nathanwailes

Fibonacci - Recursive

Jun 18th, 2024
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. def fibonacci_recursive(n):
  2.     if n <= 0:
  3.         return 0
  4.     elif n == 1:
  5.         return 1
  6.     else:
  7.         return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
  8.  
  9. # Example usage
  10. print(fibonacci_recursive(10))  # Output: 55
  11.  
Advertisement
Add Comment
Please, Sign In to add comment