Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib(n):
- if n == 0:
- sequence = []
- elif n == 1:
- sequence = [1]
- elif n == 2:
- sequence = [1, 1]
- elif n > 2:
- sequence = [1, 1]
- while len(sequence) < n:
- sequence.append(sequence[-1] + sequence[-2])
- return sequence
- print(fib(int(input("Generate how many numbers? \n "))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement