Created
July 13, 2020 14:47
-
-
Save aahnik/fbd695a460bbf59b931639b24e3fcfc0 to your computer and use it in GitHub Desktop.
This file contains 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
# General Term (x ** power)/factorial(power) | |
# where power ranges from 0 to n-1 if the series has n terms | |
def factorial(num): | |
# recursive function | |
if num == 0: | |
# base case | |
return 1 | |
else: | |
return num * factorial(num - 1) | |
def find_sum(x, n): | |
# here n is the no of terms in series, and x is given value | |
sum = 0 | |
for power in range(n): | |
sum += (x ** power) / factorial(power) | |
print(f"the required sum is {sum}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment