Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
- [1,1,2,3,5,8,13,21,34,55]
- a=int(input("write the length of numbers you would like to see the fibonacci series for(by entering 0 or 1 the output will be [1,1]): "))
- if a<0:
- print("invalid entry please type a positive number")
- else:
- i=2
- fibs=[1,1]
- b=fibs[-2]
- c=fibs[-1]
- d=b+c
- while i<a :
- i=i+1
- b=fibs[-2]
- c=fibs[-1]
- d=b+c
- fibs.append(d)
- print(fibs)
- print(",".join(map(str, fibs))) # Instead of print(fibs).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement