write a program to print S= 1/2 + 3/5 + 5/8 + …. ( 5 terms )
Answers
Answered by
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
Computer Science,
1 month ago
Math,
1 month ago
Math,
8 months ago
Chemistry,
8 months ago
English,
8 months ago