Created
March 31, 2011 03:40
-
-
Save concertman/895779 to your computer and use it in GitHub Desktop.
write the Fibonacci sequence up to n
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): #write the Fibonacci sequence up to n | |
"""Print a Fibonacci sequence up to n. """ | |
a, b = 0, 1 | |
while a < n: | |
print a, | |
a, b = b, a+b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment