Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sum_range solution in Speedy category for Sum of Integers by YurgenSlavniy
import math
def sum_upto_n(N: int) -> int:
return sum(range(1,N+1))
print("Example:")
print(sum_upto_n(11))
# These "asserts" are used for self-checking
assert sum_upto_n(1) == 1
assert sum_upto_n(2) == 3
assert sum_upto_n(3) == 6
assert sum_upto_n(4) == 10
assert sum_upto_n(5) == 15
assert sum_upto_n(10) == 55
assert sum_upto_n(20) == 210
assert sum_upto_n(100) == 5050
assert sum_upto_n(200) == 20100
assert sum_upto_n(500) == 125250
print("The mission is done! Click 'Check Solution' to earn rewards!")
Jan. 25, 2024