Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
  2.  
  3. [1,1,2,3,5,8,13,21,34,55]
  4.  
  5. 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]): "))
  6.  
  7. if a<0:
  8. print("invalid entry please type a positive number")
  9. else:
  10. i=2
  11. fibs=[1,1]
  12. b=fibs[-2]
  13. c=fibs[-1]
  14. d=b+c
  15. while i<a :
  16. i=i+1
  17. b=fibs[-2]
  18. c=fibs[-1]
  19. d=b+c
  20. fibs.append(d)
  21. print(fibs)
  22.  
  23. print(",".join(map(str, fibs))) # Instead of print(fibs).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement