Skip to content

Instantly share code, notes, and snippets.

@cameronp98
Created January 9, 2014 22:05
Show Gist options
  • Select an option

  • Save cameronp98/8342949 to your computer and use it in GitHub Desktop.

Select an option

Save cameronp98/8342949 to your computer and use it in GitHub Desktop.
Python fibonacci number generator
def fib(n):
x,y = 1,1
for i in range(n):
yield x
x,y = y, x+y
def main():
for i in range(1,10):
print(fib(i))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment