sol4r

phibonaci series

Jun 10th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. n = int(input())
  2. list = [0, 1]
  3. i = 0
  4.  
  5. if n == 1:
  6.     print(list[:1])
  7. elif n == 2:
  8.     print(list[:2])
  9. else:
  10.     a = list[0]
  11.     b = list[1]
  12.     while i < n - 2:
  13.         c = a + b
  14.         list.append(c)
  15.         a = b
  16.         b = c
  17.         i += 1
  18.     print(list)
Add Comment
Please, Sign In to add comment