Python example to find Sum of Odd Numbers

n=int(input("Enter n value:"))
sum=0
for i in range(1,n+1,2):
    sum+=i
print(sum)

OUTPUT:

Enter n value:5
9

Leave a Comment