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 Answers
+ 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