Created
January 9, 2014 22:05
-
-
Save cameronp98/8342949 to your computer and use it in GitHub Desktop.
Python fibonacci number generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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