Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum of even numbers

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

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

print("The Sum of Even Numbers from 1 to {0} = {1}".format(number, total))
Source by www.tutorialgateway.org #
 
PREVIOUS NEXT
Tagged: #sum #numbers
ADD COMMENT
Topic
Name
5+8 =