Skip to content

Instantly share code, notes, and snippets.

@ebovio
Created May 3, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebovio/d26193c0117ec38b6a826553719c08b3 to your computer and use it in GitHub Desktop.
Save ebovio/d26193c0117ec38b6a826553719c08b3 to your computer and use it in GitHub Desktop.
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x-1)
def calculate_e(precision):
e = 0
x = 0
difference = 10
for i in range (0, difference):
e = 1 / factorial(i)
x += e
x = str(x)
count = 0
while count != precision + 2:
print(x[count], end = '')
count += 1
return x
#MainProgramBelow
precision = int(input("Introduce the decimal points of accuracy you want:"))
calculate_e(precision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment