Guest User

Untitled

a guest
Feb 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. # Fibonacci series using recursion
  2. def fibonacci(n):
  3. if n == 0:
  4. return n
  5. elif n == 1:
  6. return n
  7. else:
  8. return fibonacci(n - 1) + fibonacci(n - 2)
  9.  
  10.  
  11. n = int(input("Enter how many numbers you want to print:"))
  12. print("Fibonacci sequence:")
  13. for i in range(n):
  14. print(fibonacci(i), end=' ')
Add Comment
Please, Sign In to add comment