Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum of 1 to even numbers in python

#2 + 4 + 6 + 8 + .......... + n = ?
l = int(input("Enter the range = "))
sum = 0
for x in range(2, l+1, 2):
    sum += x
    if x != l:
        print(x, "+ ", end='')
    else:
        print(x, end='')

print(" =", sum)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #numbers #python
ADD COMMENT
Topic
Name
1+7 =