Skip to content

Instantly share code, notes, and snippets.

@arjunprakash027
Last active July 20, 2025 07:06
Show Gist options
  • Save arjunprakash027/60958ccca9eb6a8d7fc98c8f5cf2f7ae to your computer and use it in GitHub Desktop.
Save arjunprakash027/60958ccca9eb6a8d7fc98c8f5cf2f7ae to your computer and use it in GitHub Desktop.
Approximating compund interest (to find e) and Maclaurin series to find similarities
def factorial(x):
if x == 1 or x == 0:
return 1
else:
return x * factorial(x - 1)
def calcualte_val(lam:int,k:int):
return ((lam ** k)/factorial(k))
def calcualte_macleairen(lamb:int,k:int):
sum = 0
for i in range(k):
sum += calcualte_val(lamb,i)
#print(sum)
return sum
def calculate_e(k:int):
return ((1 + (1/k))**k)
print(calcualte_macleairen(1,7))
print(calculate_e(100000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment