Skip to content

Instantly share code, notes, and snippets.

@rileypeterson
Created September 7, 2018 15:11
Show Gist options
  • Save rileypeterson/a5c80a2a57c4bd74b03a1bac2a049c1c to your computer and use it in GitHub Desktop.
Save rileypeterson/a5c80a2a57c4bd74b03a1bac2a049c1c to your computer and use it in GitHub Desktop.
Yield continued fraction coefficients for Napier's constant (e)
def A003417():
n = 0
while True:
if n == 0:
yield 2
if n == 1:
yield 1
else:
if (n+1) % 3 == 0:
yield int(2 * ((n+1) / 3))
else:
yield 1
n += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment