bhamini1
Can somebody please elaborate on how B is the option.Is the sum of integers between m and not equal to difference between sum of first m integers and sum of first n integers.I am not clear with this.Please explain
I was confused about this as well, I think this is how it works:
If we're looking at the number of terms between 7 and 4, inclusive, we would use First - Last + 1 --> 7 - 4 + 1 = 4
Why do we add 1 here? Because we need to include the 4 (the terms are 7,6,5 AND 4).
It's the same idea here. Let's take m = 7 and n = 4, we're looking for the sum of first 7 ints - first 4 int:
7+6+5+4+3+2+1
-______4+3+2+1
In the problem, it says inclusive, so we must include the first and last ints in the set. In this case, we have to subtract 1 from n because otherwise we will remove the 4 (and thus part of the set that we need):
7+6+5+4+3+2+1
-________3+2+1
If we use n, n+1 we would actually end up removing even more of the terms. The idea is that we're looking for a chunk of sums between the biggest number and the smallest number, but we can't remove the smallest number so we have to make sure we subtract 1 less than that smallest number.