Computer Science, asked by rukaiyajuzar, 4 months ago

s=1÷a+3÷a^3+5÷a^5+.......+n​

Answers

Answered by mohanelango001
1

Answer:

Run a loop from 1 to n and get the i-th term of the series by calculating term = (i / ai). Sum all the generated terms which is the final answer.

Explanation:

# 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):  

 

 # Math.pow(x, y) returns x^y  

 sum += (i / math.pow(a, i));  

 

return sum;  

# Driver code  

a = 3; n = 3;  

 

# Print the sum of the series  

print(getSum(a, n));  

Similar questions