Skip to content

Instantly share code, notes, and snippets.

@miku
Last active August 29, 2015 13:57
Show Gist options
  • Save miku/9496872 to your computer and use it in GitHub Desktop.
Save miku/9496872 to your computer and use it in GitHub Desktop.
def fib(k=100):
""" Generate fibonacci numbers up to k. """
a, b = 1, 2
while a <= k:
yield a
a, b = b, a + b
print(' '.join(map(str, fib())))
# prints: '1 2 3 5 8 13 21 34 55 89'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment