Last active
July 20, 2025 07:06
-
-
Save arjunprakash027/60958ccca9eb6a8d7fc98c8f5cf2f7ae to your computer and use it in GitHub Desktop.
Approximating compund interest (to find e) and Maclaurin series to find similarities
This file contains hidden or 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
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