Skip to content

Instantly share code, notes, and snippets.

@ZSendokame
Last active November 3, 2023 18:09
Show Gist options
  • Save ZSendokame/b5e87473bbedfdd7406f34920e276760 to your computer and use it in GitHub Desktop.
Save ZSendokame/b5e87473bbedfdd7406f34920e276760 to your computer and use it in GitHub Desktop.
Euler number approximation. Instead of using math.factorial, used that little trick. Discovered while thinking how to make it faster and more precise, didn't found a way to make it more precise
def euler() -> Decimal:
e = Decimal(0)
f = 1
for n in range(2, 100_000):
f *= n
e += Decimal((1 / f))
return e + 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment