Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and
including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.
I want very simple code because I am a student.
number = int(input("Enter the Number: "))
# Assigning an input variable where it asks to input your integer number
sum = 0
for value in range(1, number + 1):
#The sum = sum + value is used to find the sum
sum = sum + value
print(sum)
Comments
Leave a comment