Donate SIGN UP

(S)Um Of Consecutive Integers

Avatar Image
mibn2cweus | 22:35 Mon 05th Sep 2016 | Science
10 Answers

This formula is intended to find the sum of a consecutive series of integers between any two values.
It appears to work for both positive and negative integers including series that include zero as one of the values.

Definition of variables:
(G)reatest minus (L)east plus 1 gives (N)umber of integers in series
( G + L ) / 2 gives (A)verage value

Formula:
[ ( G - L ) + 1 ] * [ ( G + L ) / 2 ] = N * A = S

Can this formula be simplified?

Feel free to suggest alternative methods for achieving this goal.

Thanks!
Gravatar

Answers

1 to 10 of 10rss feed

Best Answer

No best answer has yet been selected by mibn2cweus. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
The sum in question is simply an arithmetic progression with common difference 1, so I don't think there's much more that needs to be done than quote that formula (in your notation):

S = N / 2 ( G + L )

This explains why it works including zero as one of the values. I also don't think that any simplification is possible - I suppose you could, say, eliminate G so that

S = N / 2 [( N - 1 ) + 2*L ]

Which also makes a neat connection to the related triangle numbers, as in that case L=1 so that S = N(N+1)/2 is the standard formula.

For the avoidance of any doubt, in this case I am using / in the sense I was describing in the R&S thread, so that N / 2 ( G + L ) implies that N is divided by 2 only
I think that you may find it useful use the formula given by jim but then to eliminate N so that the formula simply uses G and L ( and therefore avoids a separate calculation to find N)
Question Author
The purpose of solving for N is that for a large series it would save counting the number of integers.

Upon further testing it appears that my formula fails for series including both positive and negative integers.
Hmm... it should still work in that case. For example - 3 - 2 - 1 + 0 + 1 + 2 + 3 + 4 = 4. The average is (4+ (-3))/2 = 1/2, there are 8 terms so N*A = 8 *1/2 = 4; meanwhile G - L + 1 = 4 - (-3) +1 - 8, so it does work.
Question Author
As a matter of fact it does. Just wasn't expecting the answer I got . . . d'oh!
Question Author
Building on Jim’s formula -

S = N / 2 [( N - 1 ) + 2*L ]

to include an integer counter I came up with -

S = ( G - L + 1 ) / 2 [ ( G - L ) + 2L ]

Can this be simplified . . . or have I just made matters worse?
Question Author
This appears to work as well -

S = ( G - L + 1) / 2 ( G + L )
Your formula still works. I think it's just a matter of personal preference now as to how you present it.

I would suggest leaving the final division by 2 until the end to avoid any misinterpretations about what the divisor is (it could be interpreted incorrectly as 2 ( G + L )
I would also change the (G - L+1) bit to (G+1-L) to avoid any potential for ambiguity.

S = ( G +1 - L )(G+L) / 2
Question Author
//I would suggest leaving the final division by 2 until the end to avoid any misinterpretations about what the divisor is (it could be interpreted incorrectly as 2 ( G + L )//

I had noticed a certain resemblance to the (problem from hell) in R&S. ;o)

1 to 10 of 10rss feed

Do you know the answer?

(S)Um Of Consecutive Integers

Answer Question >>

Related Questions