0
We want sum all items in a range it is possible to do?
Help!
5 Respostas
+ 12
sum(range(10))
+ 10
Oma Falk The answer is hidden in the question 😂
+ 4
Yes it is possible and one such way is-
print(sum(range(1,11)))
It will add values from 1 to 10 and will result in 55. It takes 11-1 as last value.
+ 4
n = int(input())
print((n*(n+1))//2)
+ 1
but if do you want to do that in a complex way you can use Carl Gauss's method 😅