Skip to content

Instantly share code, notes, and snippets.

@f3rdy
Created October 23, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f3rdy/e9efbb68c2742348d06a to your computer and use it in GitHub Desktop.
Save f3rdy/e9efbb68c2742348d06a to your computer and use it in GitHub Desktop.
In place on list fibonacci
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