# Number of numbers between a and b and sums from x to y

This is for my benefit and curiosity and not homework.
How do you calculate the number of numbers between $1$ and $100$? How do you calculate the number of even and odd numbers between $1$ and $100$?

How can you use the grouping method (e.g. sum from $1$ to $100$ = $(1+101)x50$ or $(2+99)50))$ to find the sum of numbers from $5$ to $n$? If you're not familiar with the grouping method can you explain the intuition behind the formula for sums from $1$ to $n$: $(n(n+1)/2)$?

What is the sum of numbers from $5$ to $n$?

-
There are $100$ numbers between $1$ and $100$. When you start counting at $1$, there will be $n$ numbers between $1$ and $n$. If $n$ is even then there will be half of them even and half of them odd. The sum of numbers from $5$ to $n$ is equal to the sum of numbers from $1$ to $n$ minest the sum from $1$ to $4$. –  Amateur Jul 5 at 15:26

What is the sum of numbers from 5 to n?

$$\sum_{k = 1}^n k - \sum_{k=1}^4 k = \frac{n(n+1)}2 - \frac{4(4+1)}{2} = \frac{n(n+1)}{2} -10$$

-

If you want to calculate the sum: $$a_1+a_2+ \dots+ a_N$$

you can use the formula:

$$\frac{N \cdot (a_1+a_N)}{2}$$

where $N$ is the number of terms of the sum.

In your case,you take $a_1=5$, $a_N=n$ and $N=n-5+1$

So,the sum is equal to : $$\frac{(n+5)(n-4)}{2}=\frac{n(n+1)}{2}-10$$

-

Explain the intuition behind the formula for sums from 1 to n: (n(n+1)/2).

What is the sum of numbers from 5 to n?

Between 5 and n (inclusive) there are C = (n - 5 + 1) numbers.

The average of those numbers is: M = (5 + n) / 2

We can safely multiple the number of numbers by the average, since the distribution is linear:

sum = C * M = (n - 5 + 1) * (5 + n) / 2

If it does not seem immediately intuitive then try a geometric proof:

1. draw a graph of the numbers between 5 and n, against their values (y=x for x in {5..n}).

2. Agree that the sum you are looking for is the area under the graph.

3. Draw a horizontal line through the mean value (5+n)/2.

4. Now looking at the graph, in the n column, remove all the boxes above the average, and put them on the left end of the graph (at 5). This should bring the height of column 5 up to the average line. Now do the same for (n-1) and 6, then for (n-2) and 7. Eventually you can get every column to fit the average height.

5. It should now be clear that the area under the graph is the mean value multiplied by the number of columns.

Fortunately I am a budding artist, so I can present this explanation visually:

The blue line is the average, or mean value. We start with a wedge and end with a rectangle.

I suppose one could rotate the whole triangle above the mean line in one go. But the way I have always considered it laboriously moving boxes from column n into column 5, then from n-1 into 6, and so on...

-

Alice and Bob started work on the same day. Alice's wage the first day was $5$ dollars, the next day (she is a good worker) it was $6$ dollars, the next day it was $7$ dollars, and so on. On the last day she worked, she earned $n$ dollars.

Note that this means her total income $A$ was given by $$A=5+6+7+\cdots+n\tag{1},$$ and she worked for $n-5+1$ days.

Bob's wage the first day was $n$ dollars. But the next day his wage was decreased by a dollar, and the same happened the day after that, and so on. On his last day he got $5$ dollars.

It is clear that Bob's total income was also $A$.

I forgot to mention that Alice and Bob are "partners." Every day, their joint income was $n+5$, since that was their joint income the first day, and every day Alice's income went up by $1$, and Bob's went down by $1$, leaving their combined daily income unchanged.

Between them, they earned $2A$ dollars. Every one of the $n-4$ days, they earned a combined $n+5$ dollars, so $$2A=(n-4)(n+5).$$ It follows that $$A=\frac{(n-4)(n+5)}{2}.$$ This gives us the desired closed form expression for the sum (1).

Remark: The same "story" can be used to find a closed form for the sum $a+(a+d)+(a+2d)+\cdots +(a+md)$.

-
This might be a little tough on Alice and Bob's relationship, though. –  AJMansfield Jul 5 at 22:58