Skip to content

Instantly share code, notes, and snippets.

@ahmed4end
Created January 1, 2021 20:02
Show Gist options
  • Save ahmed4end/cb9434135554ab723fcc207c5e52d732 to your computer and use it in GitHub Desktop.
Save ahmed4end/cb9434135554ab723fcc207c5e52d732 to your computer and use it in GitHub Desktop.
#Python - Fibonacci sequence (Lazy solution).
def feb(first=0, second=1):
Next = first+second
yield Next
yield from feb(first=second, second=Next)
obj = feb()
for i in range(25):
#calculate only the next number in loop (lazy).
print(next(obj), end=' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment