Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def fib(n):
  2. if n == 0:
  3. sequence = []
  4. elif n == 1:
  5. sequence = [1]
  6. elif n == 2:
  7. sequence = [1, 1]
  8. elif n > 2:
  9. sequence = [1, 1]
  10. while len(sequence) < n:
  11. sequence.append(sequence[-1] + sequence[-2])
  12. return sequence
  13.  
  14. print(fib(int(input("Generate how many numbers? \n "))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement