Python program to calculate the sum of first to n odd number


Write a program in python to calculate the sum of first to n odd number.

----------------------------------

num=int(input("Enter the Limit : "))

sum=0

for i in range(1,num+1,2):

    sum=sum+i

print("The sum of all odd numbers are : ",sum)

----------------------------------

Output :- 

Enter the Limit : 11

The sum of all odd numbers are :  36


Post a Comment

0 Comments