Advertisement
Hoang_Gia_Phu

Câu 1: In ra dãy số Fibonaci tới số thứ n

Feb 21st, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. #DEF FUNC RECURSIVE FIBO
  2. def fibo(n):
  3.     if  n==0:
  4.         return 0
  5.     elif n==1:
  6.         return 1
  7.     else:
  8.         return (fibo(n-1) + fibo(n-2))
  9.  
  10. n = int(input())
  11. for i in range(0, n):
  12.     print(fibo(i), end = ' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement