Tuesday 20 September 2022

ch-5 pg 5.48

 Q22)

import math

x=int(input("enter x"))

n=int(input("Enter n"))

s=0

y=4

for i in range(2,n+1):

    if not i%2:

      s-=math.pow(x,i)/math.factorial(y)

    else:

      s+=math.pow(x,i)/math.factorial(y)

    y+=2

    

print("Sum is ",1-s)    

enter x2


Enter n3

Sum is  1.1555555555555554


Q23)

n=int(input("Enter n"))

s=0

for i in range(1,n+1):

    for i in range(1,i+1):

        s+=i

    

print("Sum is ",s)    


Enter n3

Sum is  10


No comments:

Post a Comment