Advertisement
rfmonk

fibonacci2.py

Dec 16th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # function
  3. # credit goes to antiloquax for all the fib scripts
  4. def fibonacci(number):
  5.     fib = [0, 1]
  6.     for i in range(number):
  7.         fib.append(fib[i] + fib[i + 1])
  8.     return(fib[i])
  9.  
  10. print("Fibonacci")
  11. request = int(input("Which item in the series?"))
  12. print(fibonacci(request))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement