InterviewSolution
Saved Bookmarks
| 1. |
To print the sum of the series using Menu Driven Program: S=2/a+3/a^2+5/a^3+7/a^4+......................till n |
|
Answer» n 3 program to find the sum of # the given series import math # FUNCTION to return the # sum of the series DEF getSum(a, n): # variable to store the ANSWER sum = 0; for i in range (1, n + 1 , 2): # Math.pow(x, y) returns x^y sum += (i / math.pow(a, i)); return sum; # DRIVER code a = int(input("enter a number :")) n = int(input("enter no. of terms")) # Print the sum of the series print(getSum(a, n)); |
|