# Formula for adding all positive integers in a given interrval?

1. Jul 1, 2013

### sherrellbc

1. The problem statement, all variables and given/known data

I meant for the title to be, Sum of all EVEN integers
A formula to add all even integers between two given points.
(i.e.) All integers from 6 to 2000 ?
6+8+10+12 .. + 2000

3. The attempt at a solution
The reason I ask is because I derived such an equation that will work for any integer interval. Just curious to see what any similar formula would look like.

Surely there is something like this.

Last edited: Jul 1, 2013
2. Jul 1, 2013

### Dick

Surely there is. It's just the sum of an arithmetic series. See https://en.wikipedia.org/wiki/Arithmetic_progression

3. Jul 1, 2013

### sherrellbc

Interesting. The Arithmetic series illustrates on this page is pretty much exactly what I derived, although mine being for a special case of the constant difference being two.

The difference being that the equations given on the Wiki article assume that you know how many integers you are adding together; the formula I derived does not. I simply expanded on this notion of needing to know the total number of integers to add and derived a generalized form of it. So, that being said, its already exists. Anyway, here is what I came up with.

Given a closed interval [a,b] of positive integers, the sum is nothing more than:

4. Jul 1, 2013

### sherrellbc

This could be extensively useful in algorithms. Perhaps you are not aware of the length of Integers to add.

Albeit very specific, the formula could be useful.

5. Jul 2, 2013

### Mentallic

If you look further down, there's the more general formula for an arithmetic sum where the difference between each value is d (in your case, 2)

$$S_n = \frac{n}{2}\left(2a+(n-1)d\right)$$

With d=2 we get

$$S_n = \frac{n}{2}\left(2a+2n-2\right)$$

$$=n(a+n-1)$$

But if you want the formula to be in terms of only the first and last values of the series, then you'll get to the result you've shown.