Computer Science

Write Python programs to sum the given sequences:

2/9 - 5/13 + 8/17 …… (print 7 terms)

Python

Python Control Flow

31 Likes

Answer

n = 2 #numerator initial value
d = 9 #denominator initial value
m = 1 #to add/subtract alternate terms
sum = 0

for i in range(7) :
    t = n / d
    sum += t * m
    n += 3
    d += 4
    m *= -1
    
print("Sum =", sum)

Output

Sum = 0.3642392586003134

Answered By

11 Likes


Related Questions