Computer Science, asked by bhavnapanda0401, 7 months ago

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

Answers

Answered by GamerAzim
0

# Python 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));  

Similar questions