Help me solve this: Sum= 1+2+3+4+...+100 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Help me solve this: Sum= 1+2+3+4+...+100

7th Dec 2017, 9:41 AM
Phan Ngô Tuấn Kiệt
Phan Ngô Tuấn Kiệt - avatar
7 Answers
7th Dec 2017, 10:08 AM
Akash Pal
Akash Pal - avatar
+ 5
(100 + 1) * 50 Gauss was great!
7th Dec 2017, 11:06 AM
Oma Falk
Oma Falk - avatar
+ 4
Why don't you try it yourself, and post the code if you have trouble? We'll be here to help. 😉
7th Dec 2017, 9:45 AM
blackcat1111
blackcat1111 - avatar
+ 4
try this, hope it helps i = 1 sum = 0 while i ≤ 100: sum += i print(sum)
7th Dec 2017, 10:07 AM
Fredy XD
Fredy XD - avatar
+ 3
i'll try, thanx @blackcat1111
7th Dec 2017, 9:47 AM
Phan Ngô Tuấn Kiệt
Phan Ngô Tuấn Kiệt - avatar
+ 3
1+100=101 2+99=101 and so on untill 50+51=101 so... 50*101
7th Dec 2017, 9:58 AM
Amir Galanty
Amir Galanty - avatar
+ 3
use the sum of arithmetic progression : Sn = n*(2*a+(n-1)*d)/2 For your question n = 100 a = 1 d = 1 Therefore : Sn = 100*(2+99)/2 = 50*101 = 5050 Thus the sum is : 5050
7th Dec 2017, 10:01 AM
RZK 022
RZK 022 - avatar