Using a while loop which stops due to meeting a tolerance co
Using a while loop which stops due to meeting a tolerance condition, design functions to find the following sums. Use recursion wherever possible. Also note, there is no x in any of these sums. So there should not be one in your functions. sigma_n=1^infinity 1/n! sigma_n=1^infinity (2n)!/(3n)! sigma_n=1^infinity 100^n/n! sigma_n=1^infinity n/2^n
Solution
# Hello World program in Python
def fact(n): #defining factorial function
if n=1: #checking condition for n=1
return 1 #returning value 1
else
return n*fact(n-1) #recursively calling the fact function
m=1 #intializing variable m with 1
sum1=0 #intializing variable sum1 with 0
sum2=0 #intializing variable sum2 with 0
sum3=0 #intializing variable sum3 with 0
sum4=0 #intializing variable sum4 with 0
while m<10: #checking for m less than 10
sum1=sum1+(1/fact(m))
sum2=sum2+((fact(2*m))/(fact(3*m)))
sum3=sum3+((100**m)/fact(m))
sum4=sum4+(m/(2**m))
m=m+1
