Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How do you sum consecutive numbers in Python?

N = int(input("Please input an integer: "))
i = 1
x = range(1, N + 1)
for i in x:
    nums = range(1, i + 1)
print(int(sum(nums)))


Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #sum #consecutive #numbers
ADD COMMENT
Topic
Name
2+4 =