Advertisement
daixso

Fibonacci Sequence

Jul 25th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. i=0 #counting variable
  2. a=0 #first term in the sequence
  3. b=1 #second term in the sequence
  4. terms=100 #set the number of times for the loop to run
  5.  
  6. while i<=terms:
  7.     print a
  8.     num=a+b #store last number in sequence
  9.     a=b #set first term again
  10.     b=num #set second term again
  11.     i+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement