Formula for adding all positive integers in a given interrval?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
sherrellbc
Messages
83
Reaction score
0

Homework Statement

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

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:
Physics news on Phys.org
sherrellbc said:

Homework Statement




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

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.

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

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:
RCJXDuD.jpg
 
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.
 
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)

[tex]S_n = \frac{n}{2}\left(2a+(n-1)d\right)[/tex]

With d=2 we get

[tex]S_n = \frac{n}{2}\left(2a+2n-2\right)[/tex]

[tex]=n(a+n-1)[/tex]

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.