Advertisement
pacho_the_python

fib_recursive

Apr 22nd, 2024
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def fibonacci_recursive(n):
  2.     if n <= 1:
  3.         return n
  4.     else:
  5.         return fibonacci_recursive(n-1) + fibonacci_recursive(n-2)
  6.  
  7. def fibonacci_sequence(num):
  8.     if num <= 0:
  9.         return "Please enter a positive integer."
  10.     sequence = [fibonacci_recursive(i) for i in range(num)]
  11.     return f'{", ".join(map(str, sequence))}'
  12.  
  13.  
  14. print(fibonacci_sequence(11))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement