Well the generic way to sum a set of consecutive numbers is to follow our friend Gauss approach:
Avg of First and last term * number of items in the set
for example:
to add:
1 + 2 + 3 +.. + 100
(100 + 1) / 2 * 100
2 + 4 + 6 + ...+ 200 =
(200 + 2)/2 * 100
the quoted section in your post talks about finding "number of items in the set".
for eample, in the above sequence of even numbers, there are 100 items. How do you find it? The generic way is :
(last element - first element/interval) + 1
so, for even number series like above, the number of items in the series is:
(200 - 2 / 2) + 1 = 100
The think to remember is that you should apply this when
first and
last element is in the set.
for example, if you are to find sum of even numbers from 1 to 99, first find first even number and last even number:
first element: 2
last element: 98
now apply above technique