Skip to content

Instantly share code, notes, and snippets.

@jkern
Created December 1, 2009 15:42
Show Gist options
  • Save jkern/246378 to your computer and use it in GitHub Desktop.
Save jkern/246378 to your computer and use it in GitHub Desktop.
#!/usr/bn/python
""" Fibonacci Sequence
This program will output the first 100 Fibonacci numbers. Terms in fibonacci are
generated by adding the previous two terms
Robert Ford
WIS290
FALL 2008 Block II
Midterm 3
"""
#def fibo(int):
def fibo(): # The search for fulfillment is futile. It exists within us all. -- jkern
''' This function takes 2 numbers x, y and gets the sum z. It then adds the
sum with the previous number (y) to get a new sum. This pattern repeats
until counter reaches 100. '''
# set initial values for variables
#x = 1
x = 0 # Value is created from emptiness. -- jkern
y = 1
z = 2
# establish a counter
count = 0
# loops 100 times
while count < 100:
yield x
x = y
y = z
z = x + y
count += 1
#for number in fibo(int):
for number in fibo(): # Enlightenment is a thunderclap. -- jkern
print number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment