0

I need to write a program to Take a number N as input and output the sum of all numbers from 1 to N (including N).

27th Jan 2022, 6:26 AM
Artin !!!
Artin !!! - avatar
4 Respostas
+ 1
n = int(input()) sum = 0 for i in range(n+1): sum += i print(sum)
27th Jan 2022, 6:35 AM
Рената Ремизова
Рената Ремизова - avatar
+ 3
print(sum(range(int(input())+1)))
27th Jan 2022, 9:28 AM
SoloProg
SoloProg - avatar
+ 1
You can also do it like this by using a formula!! N=int(input()) print(int(N*(N+1)/2))
27th Jan 2022, 6:49 AM
NEZ
NEZ - avatar
0
The input is358 And the expected output must be 64261
27th Jan 2022, 6:43 AM
Artin !!!
Artin !!! - avatar