Created
December 10, 2018 12:23
-
-
Save caulagi/3edea8cf734495f2592528a48f99e1d2 to your computer and use it in GitHub Desktop.
Fibonacci Await
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
import asyncio | |
async def fibonacci(n, marker): | |
print(f'Marker: {marker}') | |
if n < 2: | |
return 1 | |
return await fibonacci(n-1, marker) + await fibonacci(n-2, marker) | |
async def main(): | |
await asyncio.gather( | |
fibonacci(5, 'A'), | |
fibonacci(6, 'B'), | |
) | |
asyncio.run(main()) |
Author
caulagi
commented
Dec 10, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment