Add up All The Integers Between 1 And 100, Inclusive.
- First you need to realize that you have to rearrange the terms to pairs up the numbers;
S = 1+2+3+4+5+........+97+98+99+100
= (1+100)+(2+99)+(3+98)+.....+(50+51)
= 101 * 50
= 5050
Formula : n(A + B)/2
n = Total no. of numbers
A = First No.
B = Last No.
So, n = Total No. = 100,
A = First No. = 1,
B = Last No. = 100
Now, According to the formula : 100(1 + 100) / 2
= 50 * 101
= 5050
- Similarly,
Then, S = 1+2+3+......+99+100+101
Now, According to the formula : 101(1 + 101) / 2
= 101 * 51
= 5151
Comments
Post a Comment