Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Sum of Integers by Katharina_Hausler
def sum_upto_n(N):
return N * (N+1)//2
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. 12, 2024
Comments: