45.WAP to display sum of following series(Sum of Inverse Factorial Series with simultaneous sign)
s=1/1! - 1/2! + 1/3! - 1/4! + ....
CODE:
sum=0
fact=1
sign=1
n=int(input("How many terms?\n"))
for i in range(1,n+1):
fact=fact*i
sum=sum+(sign*(1/fact))
sign=-sign
print("Sum of series is ",sum)OUTPUT:How many terms?
2
Sum of series is 0.5
Comments
Post a Comment