Title: Sum of the odd
numbers up to the specified number
Sum of
the up to 10 odd numbers is
1+3+5+7+9=25
Program:
n=int(input("Enter n
value\n"))
sum=0
for i in range(1,n+1,2):
sum=sum+i
print("Sum of upto
",n," odd numbers is",sum)
Output:
Enter
n value
10
Sum of
upto 10
odd numbers is 25
Comments
Post a Comment