Answer to Question #265942 in Python for H A

Question #265942

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


1
Expert's answer
2021-11-14T09:21:46-0500
def sum_to(n):
	sum = 0
	for i in range(1, n + 1):
		sum += i
	return sum
	
print(sum_to(10))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS