117. Python Program to Compute the 1+3+5+7+9+ …….+n Series.
How does this program work?
- This program is used to find the Sum of the given series 1+3+5+7+9+ …….+n using Python.
- The integer entered by the user is stored in variable n i.e last term for the given series.
- By using for loop we can find the sum of series for odd numbers upto nth term.
Here is the code
n = int(input("Enter a number: "))
num = 0
print("Series till the enter number: ")
for i in range(1,n+1):
if(i%2!=0):
print(i, end=" ")
num+=i
print("\nSum of the series: ",num)