Sum of all numbers between A and B

mackdaddy

Junior Member
Joined
Mar 6, 2013
Messages
58
I have found a formula to find the sum of all numbers between A and B, where B>A

It's like so

(B^2-A^2-B-A)/2=the sum of all numbers between A and B

Ex. A=2 B=6

(6^2-2^2-6-2)/2= 3+4+5

(36-4-6-2)/2=12
(24)/2=12
12=12
Could you please maybe explain and eloborate on this cool formula
 
I have found a formula to find the sum of all numbers between A and B, where B>A

It's like so

(B^2-A^2-B-A)/2=the sum of all numbers between A and B

Ex. A=2 B=6

(6^2-2^2-6-2)/2= 3+4+5

(36-4-6-2)/2=12
(24)/2=12
12=12
Could you please maybe explain and eloborate on this cool formula
Congratulations on your discovery although it is somewhat oddly stated.

There is a well known formula for the sum of all positive integers from 1 through n, namely

\(\displaystyle \displaystyle \sum_{i=1}^ni = \dfrac{n(n + 1)}{2} = \dfrac{n^2 + n}{2}.\)

So, from that proposition, it is easy to show that the sum of all positive integers greater than m through n =

\(\displaystyle \displaystyle \sum_{i=m+1}^ni = \sum_{i=1}^n - \sum_{i=1}^{m}i = \dfrac{n(n + 1)}{2} - \dfrac{m(m + 1)}{2} = \dfrac{n^2 + n}{2} - \dfrac{m^2 + m}{2} = \dfrac{n^2 + n - m^2 - m}{2}.\)

The trick is proving the initial formula, which is easy if you know about proofs by mathematical induction. Do you?

There is a story that the mathematician Gauss discovered the initial formula when he was in kindergarten. Of course the initial formula has been known for millennia, but it is really cool that you found a consequent independently.
 
Thank you for this explanation! The original formula is beyond my grasp (I'm in 9th grade)(I assume it's Calculus) but the rest of the explanation is greatly appreciated! Also it's good to know I'm not the first person to discover this! Thanks again!
 
Congratulations on your discovery although it is somewhat oddly stated.

There is a well known formula for the sum of all positive integers from 1 through n, namely

\(\displaystyle \displaystyle \sum_{i=1}^ni = \dfrac{n(n + 1)}{2} = \dfrac{n^2 + n}{2}.\)

So, from that proposition, it is easy to show that the sum of all positive integers greater than m through n =

\(\displaystyle \displaystyle \sum_{i=m+1}^ni = \sum_{i=1}^n - \sum_{i=1}^{m}i = \dfrac{n(n + 1)}{2} - \dfrac{m(m + 1)}{2} = \dfrac{n^2 + n}{2} - \dfrac{m^2 + m}{2} = \dfrac{n^2 + n - m^2 - m}{2}.\)

The trick is proving the initial formula, which is easy if you know about proofs by mathematical induction. Do you?

There is a story that the mathematician Gauss discovered the initial formula when he was in kindergarten. Of course the initial formula has been known for millennia, but it is really cool that you found a consequent independently.



Also I have a question about your explanation. You end up with n^2+n-m^2-m/2 when shouldn't it be n^2-n-m^2-m/2 because say you have n=6 and m=2
you then use the formula you provided 6(6+1)/2 - 2(2+1)/2

you can reduce this to 21-3 which equals 18 but the sum of 3,4,and 5 is 12. so you have to take out an "n" instead o adding an "n" so 18-6=12
 
Thank you for this explanation! The original formula is beyond my grasp (I'm in 9th grade)(I assume it's Calculus) but the rest of the explanation is greatly appreciated! Also it's good to know I'm not the first person to discover this! Thanks again!
Proofs by induction are usually taught somewhat later than 9th grade, but the basic formula is a cinch to understand.

\(\displaystyle 1 = \dfrac{1 * 2}{2}\)

\(\displaystyle 1 + 2 = 3 = \dfrac{2 * 3}{2}\)

\(\displaystyle 1 + 2 + 3 = 6 = \dfrac{3 * 4}{2}\)

\(\displaystyle 1 + 2 + 3 + 4 = 10 = \dfrac{4 * 5}{2}\)

And so on
 
1,2=A,[3,4,5],6=B

You want sum (1,2,3,4,5) - sum(1,2);
or sum(1 to B-1) - sum(1 to A)
OK?

Using the standard formula Jeff gave you:
sum(1 to B-1) = (B-1)(B) / 2
sum(1 to A) = (A)(A+1) / 2

So: (B-1)(B) / 2 - (A)(A+1) / 2
Simplify:
(B^2 - B - A^2 - A) / 2

Looks quite a bit with what you got :p


Yes! thank you! Jeff just made one error in his standard formula because he used n(n+1)/2 - m(m + 1)/2 the m+1 caused his equation to include the "m" in the sum p.s. that Gauss guy was good I'm in ninth grade but wow! Kindergarden!
 
Proofs by induction are usually taught somewhat later than 9th grade, but the basic formula is a cinch to understand.

\(\displaystyle 1 = \dfrac{1 * 2}{2}\)

\(\displaystyle 1 + 2 = 3 = \dfrac{2 * 3}{2}\)

\(\displaystyle 1 + 2 + 3 = 6 = \dfrac{3 * 4}{2}\)

\(\displaystyle 1 + 2 + 3 + 4 = 10 = \dfrac{4 * 5}{2}\)

And so on

Ok I understand the formula but to prove something with this how you would do so?
 
Also I have a question about your explanation. You end up with n^2+n-m^2-m/2 when shouldn't it be n^2-n-m^2-m/2 because say you have n=6 and m=2
you then use the formula you provided 6(6+1)/2 - 2(2+1)/2

you can reduce this to 21-3 which equals 18 but the sum of 3,4,and 5 is 12. so you have to take out an "n" instead o adding an "n" so 18-6=12
I said in my first post that you had stated your proposition somewhat oddly. Not wrong, just in a way that is a bit confusing. I see now that I did not quite answer your question

In your first post, you gave an example where A = 2 and B = 6 and then you added up 3 + 4 + 5 = 12.

In the formula I gave you, n would be equal 5 in that example. I should have paid closer attention to the way that you used your symbols. Sorry about that.

(25^2 + 5 - 2^2 - 2)/2 = (25 + 5 - 4 - 2)/2 = 24/2 = 12 = 3 + 4 + 5.

I should have derived the formula the way you gave it

\(\displaystyle \displaystyle \sum_{i=m+1}^{n-1}i = \sum_{i=1}^{n-1}i - \sum_{i=1}^mi = \dfrac{(n - 1)n}{2} - \dfrac{m(m + 1)}{2} = \dfrac{n^2 - n - m^2 - m}{2}.\)
 
I said in my first post that you had stated your proposition somewhat oddly. Not wrong, just in a way that is a bit confusing. I see now that I did not quite answer your question

In your first post, you gave an example where A = 2 and B = 6 and then you added up 3 + 4 + 5 = 12.

In the formula I gave you, n would be equal 5 in that example. I should have paid closer attention to the way that you used your symbols. Sorry about that.

(25^2 + 5 - 2^2 - 2)/2 = (25 + 5 - 4 - 2)/2 = 24/2 = 12 = 3 + 4 + 5.

I should have derived the formula the way you gave it

\(\displaystyle \displaystyle \sum_{i=m+1}^{n-1}i = \sum_{i=1}^{n-1}i - \sum_{i=1}^mi = \dfrac{(n - 1)n}{2} - \dfrac{m(m + 1)}{2} = \dfrac{n^2 - n - m^2 - m}{2}.\)

Ok yes I see now what you were saying ok, so either way will give you the same answer. Thanks again!
 
Ok I understand the formula but to prove something with this how you would do so?
Well we just did prove something with it.

It's a little formula that comes up from time to time.

If you are asking about HOW we prove it, the most usual way is by a method called weak mathematical induction. Here is the idea, which is sort of intuitive. First we prove that the proposition is true for 1. Then we prove that if it is true for any number, it is true for the number 1 greater. So if it is true for 1, it is true for 2, but that makes it true for 3, which inturn proves it for 4, and so on forever. Pretty neat.

So \(\displaystyle 1 = \dfrac{2}{2} = \dfrac{1 * 2}{2} = \dfrac{1(1 + 1)}{2}.\) We just proved it for 1.

So we know that there is at least one number for which it is true. So let's analyze any one of those numbers (we do not know how many there are yet, but we do know that there is at least 1.)

\(\displaystyle \displaystyle \sum_{i=1}^ki = \dfrac{k(k + 1)}{2}.\) So

\(\displaystyle \displaystyle \sum{i=1}^{k+1}i = k + 1 + \sum_{i=1}^ki = k + 1 + \dfrac{k(k + 1)}{2} = \dfrac{2k + 2 + k^2 + k}{2} =\dfrac{k^2 + 3k + 2}{2} = \dfrac{(k + 1)(k + 2)}{2} = \dfrac{(k + 1)\{(k + 1) + 1\}}{2}.\)

If it is true for k it is true for k+1.

Do not worry if this proof eludes you. This kind of proof is not usually taught before college.
 
I said in my first post that you had stated your proposition somewhat oddly. Not wrong, just in a way that is a bit confusing. I see now that I did not quite answer your question

In your first post, you gave an example where A = 2 and B = 6 and then you added up 3 + 4 + 5 = 12.

In the formula I gave you, n would be equal 5 in that example. I should have paid closer attention to the way that you used your symbols. Sorry about that.

(25^2 + 5 - 2^2 - 2)/2 = (25 + 5 - 4 - 2)/2 = 24/2 = 12 = 3 + 4 + 5.

I should have derived the formula the way you gave it

\(\displaystyle \displaystyle \sum_{i=m+1}^{n-1}i = \sum_{i=1}^{n-1}i - \sum_{i=1}^mi = \dfrac{(n - 1)n}{2} - \dfrac{m(m + 1)}{2} = \dfrac{n^2 - n - m^2 - m}{2}.\)

Oh I just wanted to show you how I got to this formula, this might take a little while!
A while back I realized that A^2 + (A+B) + 2(sum of #s between A and B)= B^2

I then saw how this lines up with pythagorean theorem (a^2+b^2=c^2) where a=A c=B and b^2=(A+B) + 2(sum of #s between A and B)

I also knew that "b^2" is equal to the difference of squares (a+c)(a-c) or in this case (A+B)(A-B)

so I set (A+B)(A-B)=(A+B) + 2(sum of #s between A and B)

then I divided by (A+B) to get (A-B)=1 + 2(sum of #s between A and B)/(A+B)

then I subtracted 1 to get (A-B-1)= 2(sum of #s between A and B)/(A+B)

then I multiplied by (A+B) to get A^2-B^2-A-B=2(sum of #s between A and B)

Finally I just divided by two to get the formula!
It was quite the longer route but it worked eventually!
 
Well we just did prove something with it.

It's a little formula that comes up from time to time.

If you are asking about HOW we prove it, the most usual way is by a method called weak mathematical induction. Here is the idea, which is sort of intuitive. First we prove that the proposition is true for 1. Then we prove that if it is true for any number, it is true for the number 1 greater. So if it is true for 1, it is true for 2, but that makes it true for 3, which inturn proves it for 4, and so on forever. Pretty neat.

So \(\displaystyle 1 = \dfrac{2}{2} = \dfrac{1 * 2}{2} = \dfrac{1(1 + 1)}{2}.\) We just proved it for 1.

So we know that there is at least one number for which it is true. So let's analyze any one of those numbers (we do not know how many there are yet, but we do know that there is at least 1.)

\(\displaystyle \displaystyle \sum_{i=1}^ki = \dfrac{k(k + 1)}{2}.\) So

\(\displaystyle \displaystyle \sum{i=1}^{k+1}i = k + 1 + \sum_{i=1}^ki = k + 1 + \dfrac{k(k + 1)}{2} = \dfrac{2k + 2 + k^2 + k}{2} =\dfrac{k^2 + 3k + 2}{2} = \dfrac{(k + 1)(k + 2)}{2} = \dfrac{(k + 1)\{(k + 1) + 1\}}{2}.\)

If it is true for k it is true for k+1.

Do not worry if this proof eludes you. This kind of proof is not usually taught before college.

Ok I see the main jist of it, thanks!
 
Oh I just wanted to show you how I got to this formula, this might take a little while!
A while back I realized that A^2 + (A+B) + 2(sum of #s between A and B)= B^2

In terms of a proof, this starting point is not satisfactory because there is no reason to accept it. HOWEVER, in 9th grade you are unlikely to have been taught how to do proofs. In any case, it is very, very commendable that you discovered this numerical relationship. From this point on, your derivation is basically sound although marred by a simple error. Who am I to talk about errors? I live in the corner.

I then saw how this lines up with pythagorean theorem (a^2+b^2=c^2) where a=A c=B and b^2=(A+B) + 2(sum of #s between A and B)

The Pythagorean Theorem would never have occurred to me in this context. Very creative of you, but it adds an unnecessary step.

\(\displaystyle A^2 + (A + B) + 2\left(\displaystyle \sum_{i=A+1}^{B-1}i\right) = B^2 \implies A^2 + \left(\sqrt{A + B + 2\displaystyle \sum_{i=A + 1}^{B-1}i}\right)^2 = B^2 \implies \left(\sqrt{A + B + 2\displaystyle \sum_{i=A + 1}^{B-1}i}\right)^2 = B^2 - A^2. \)

I also knew that "b^2" is equal to the difference of squares (a+c)(a-c) or in this case (A+B)(A-B) Here is your error. It needs to be
(B + A)(B - A).

so I set (A+B)(A-B)=(A+B) + 2(sum of #s between A and B)

\(\displaystyle \left(\sqrt{A + B + 2\displaystyle \sum_{i=A + 1}^{B-1}i}\right)^2 = B^2 - A^2 = (B + A)(B - A) \implies A + B +\displaystyle 2 \left(\sum_{i=A+1}^{B - 1}i\right) = (B + A)(B - A).\)

then I divided by (A+B) to get (A-B)=1 + 2(sum of #s between A and B)/(A+B)

\(\displaystyle A + B +\displaystyle 2 \left(\sum_{i=A+1}^{B - 1}i\right) = (B + A)(B - A) \implies 1 + \left(\dfrac{2}{B + A} * \sum_{i=A+1}^{B-1}i\right) = B - A.\)

then I subtracted 1 to get (A-B-1)= 2(sum of #s between A and B)/(A+B)

\(\displaystyle 1 + \left(\dfrac{2}{B + A} * \displaystyle \sum_{i=A+1}^{B-1}i\right) = B - A \implies \left(\dfrac{2}{B + A} * \displaystyle \sum_{i=A+1}^{B-1}i\right) = B - A - 1.\)

then I multiplied by (A+B) to get A^2-B^2-A-B=2(sum of #s between A and B)

\(\displaystyle \left(\dfrac{2}{B + A} * \displaystyle \sum_{i=A+1}^{B-1}i\right) = B - A - 1 \implies 2\left(\displaystyle \sum_{i=A+1}^{B-1}i\right) = (B - A - 1)(B + A) = B^2 - A^2 - B - A.\)

Finally I just divided by two to get the formula!

\(\displaystyle 2\left(\displaystyle \sum_{i=A+1}^{B-1}i\right) = B^2 - A^2 - B - A \implies \displaystyle \sum_{i=A+1}^{B-1}i = \dfrac{B^2 - A^2 - B - A}{2}.\)

It was quite the longer route but it worked eventually!
I was not doing stuff like that in the 9th grade.

I will tell you the story (it is not confirmed history) of how Gauss supposedly discovered for himself in kindergarten the basic rule about the sum of successive numbers.

The story goes that the teacher needed to keep the students busy for a while so asked them to add up all the numbers from 1 through 100 by hand. Gauss ruined that plan by solving the problem in just a few minutes this way

1 + 100 = 101

2 + 99 = 101

3 + 98 = 101

So 1 + 2 + ... 100 = 50 * 101 = 100 * 101 / 2.

The story may be true; Gauss was a brilliant mathematician at a very early age.
 
I was not doing stuff like that in the 9th grade.

I will tell you the story (it is not confirmed history) of how Gauss supposedly discovered for himself in kindergarten the basic rule about the sum of successive numbers.

The story goes that the teacher needed to keep the students busy for a while so asked them to add up all the numbers from 1 through 100 by hand. Gauss ruined that plan by solving the problem in just a few minutes this way

1 + 100 = 101

2 + 99 = 101

3 + 98 = 101

So 1 + 2 + ... 100 = 50 * 101 = 100 * 101 / 2.

The story may be true; Gauss was a brilliant mathematician at a very early age.

Wow! Thats incredible! And thank you for pointing out that error! I thought it was very interesting how in using (A+B) + 2(sum of #s between A and B), you found
B^2-A^2. It's also useful in finding squares of numbers like 23 and such. I wonder if you wanted to find the sum of the #s between A^2 and B^2 would you just square the whole formula?
 
Wow! Thats incredible! And thank you for pointing out that error! I thought it was very interesting how in using (A+B) + 2(sum of #s between A and B), you found
B^2-A^2. It's also useful in finding squares of numbers like 23 and such.
I wonder if you wanted to find the sum of the #s between A^2 and B^2 would you just square the whole formula?

Never mind it would be (B^4-B^2-A^4-A^2)/2, so you would just square each term seperately (except 2) instead of squaring the entire formula.
 
Wow! Thats incredible! And thank you for pointing out that error! I thought it was very interesting how in using (A+B) + 2(sum of #s between A and B), you found
B^2-A^2. It's also useful in finding squares of numbers like 23 and such. I wonder if you wanted to find the sum of the #s between A^2 and B^2 would you just square the whole formula?
In general, the sum of squares is NOT equal to the square of sums.

\(\displaystyle 3^2 + 4^2 = 9 + 16 = 25 \ne 49 = 7^2 = (3 + 4)^2.\)

All I was doing was following your logic symbolically.

Now since you seem to be interested in neat formulas, I'll show you one (without proof)

\(\displaystyle a^n - b^n = (a - b)\{a^{(n-1)} + a^{(n-2)}b\ +\ ...\ ab^{(n-2)} + b^{(n-1)}\}.\)

In other words, \(\displaystyle a^2 - b^2 = (a - b)(a + b)\) is just the first in an infinite series of formulas called difference of powers.

Let's look at the first few

\(\displaystyle (a - b)(a^2 + ab + b^2) = a^3 + a^2b + ab^2 - a^2b - ab^2 - b^3 = a^3 - b^3.\)

\(\displaystyle (a - b)(a^3 + a^2b + ab^2 + b^3) = a^4 + a^3b + a^2b^2 + ab^3 - a^3b - a^2b^2 - ab^3 - b^4 = a^4 - b^4.\)

Have fun with math.
 
In general, the sum of squares is NOT equal to the square of sums.

\(\displaystyle 3^2 + 4^2 = 9 + 16 = 25 \ne 49 = 7^2 = (3 + 4)^2.\)

All I was doing was following your logic symbolically.

Now since you seem to be interested in neat formulas, I'll show you one (without proof)

\(\displaystyle a^n - b^n = (a - b)\{a^{(n-1)} + a^{(n-2)}b\ +\ ...\ ab^{(n-2)} + b^{(n-1)}\}.\)

In other words, \(\displaystyle a^2 - b^2 = (a - b)(a + b)\) is just the first in an infinite series of formulas called difference of powers.

Let's look at the first few

\(\displaystyle (a - b)(a^2 + ab + b^2) = a^3 + a^2b + ab^2 - a^2b - ab^2 - b^3 = a^3 - b^3.\)

\(\displaystyle (a - b)(a^3 + a^2b + ab^2 + b^3) = a^4 + a^3b + a^2b^2 + ab^3 - a^3b - a^2b^2 - ab^3 - b^4 = a^4 - b^4.\)

Have fun with math.

Oh cool! one last question. I know Fermat's last theorem was only proved a little while back and by a genius who used impossible methods to prove it, but could one maybe use the difference of powers formulas and some form of weak induction together to prove at least part of his theorem of a^n+b^n does not = c^n if n>2
 
Oh cool! one last question. I know Fermat's last theorem was only proved a little while back and by a genius who used impossible methods to prove it, but could one maybe use the difference of powers formulas and some form of weak induction together to prove at least part of his theorem of a^n+b^n does not = c^n if n>2
I do not know. I am not a mathematician: I merely help out answering questions in elementary algebra. Questions like that maybe could be asked in the Odds and Ends forum, which is sort of a place where the tutors hang out so be sure to tell them you are in 9th grade. Someone there may know something about how Fermat's Last Theorem was proved. The problem may be that understanding the method used will require a lot of fairly advanced math: sometimes seemingly simple problems require a lot of fire power to solve.
 
I'm VERY surprised that no one commented on the part of the original post (and also quoted in numerous responses) which said "the sum of all numbers between A and B". The original posted then proceeded to deal with an example where A = 2 and B = 6, which handled the numbers 3, 4, and 5. There are INFINITELY many numbers between 2 and 6, such as 2.75, 3.1010010001......, pi, 9/2, etc.

I think you need to re-phrase your statement to say "all whole numbers between A and B."

Otherwise, I am impressed with the depth of thought and comprehension displayed by a 9th grader here! Congratulations!
 
Product of all numbers between A and B

Fun Idea Mrspi.


Sum of all numbers between A and B (both same sign) is infinite,
HOWEVER, the average of all numbers between A and B (both same sign) is finite,
Challenge: Can anyone calculate the Geometric mean of all numbers between 0 and 1?
 
Last edited:
Top