Created
October 23, 2015 17:30
-
-
Save f3rdy/e9efbb68c2742348d06a to your computer and use it in GitHub Desktop.
In place on list fibonacci
This file contains 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(maximum): | |
""" | |
Calculate the fibonacci numbers below maximum | |
:param maximum: the maximum number | |
:return: a list containing fibonacci numbers | |
""" | |
result = [1, 1] | |
while True: | |
result.append(result[len(result)-2] + result[len(result)-1]) | |
if result[len(result)-1] > maximum: | |
result.pop() | |
return result | |
def main(): | |
for i in fib(5000): | |
print i | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment