Computer Science, asked by kuljeetsingh250983, 2 months ago

write a program to print S= 1/2 + 3/5 + 5/8 + …. ( 5 terms )​

Answers

Answered by allysia
1

Language:

Python

Program:

sum ,a,b=0,1,2

for i in range(0, int(input("Enter the last limit: "))):

   sum+=a/b

   b+=3

   a+=2

print(sum)

Output:

Enter the last limit: 3

1.725

Explanation:

  • input( ) accepts input for the last limit for for loop. ( pfft )
  • something+= other_thing increases the value of something by other_thing.
  • The final line print the last value of sum in the loop.

Similar questions