Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

summing all Odd Numbers from 1 to N

# Python Program to Calculate Sum of Odd Numbers from 1 to N
 
maximum = int(input(" Please Enter the Maximum Value : "))
Oddtotal = 0

for number in range(1, maximum+1, 2):
    print("{0}".format(number))
    Oddtotal = Oddtotal + number

print("The Sum of Odd Numbers from 1 to {0} = {1}".format(number, Oddtotal))
Source by www.tutorialgateway.org #
 
PREVIOUS NEXT
Tagged: #summing #Odd #Numbers #N
ADD COMMENT
Topic
Name
2+7 =