1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Formula for adding all positive integers in a given interrval?

  1. Jul 1, 2013 #1
    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. jcsd
  3. Jul 1, 2013 #2

    Dick

    User Avatar
    Science Advisor
    Homework Helper

    Surely there is. It's just the sum of an arithmetic series. See https://en.wikipedia.org/wiki/Arithmetic_progression
     
  4. Jul 1, 2013 #3
    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
     
  5. Jul 1, 2013 #4
    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.
     
  6. Jul 2, 2013 #5

    Mentallic

    User Avatar
    Homework Helper

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted