# Math Help - [SOLVED] Sum of numbers between 2 numbers, formula?

1. ## [SOLVED] Sum of numbers between 2 numbers, formula?

Hi,

Sorry if this is in the wrong section, I did maths a year and a bit back in high school and im doing computing at uni, and I'm not sure on the exact formula I need.

I need it to double check that my program is outputting the right sum.

I need the formula to calculate the sum of the numbers between 200 and 300 inclusively.

the sum my program is giving me is 25250

I cant even remember doing this with numbers being inclusive or exclusive.

so could someone please explain the difference between inclusive and exclusive numbers, and the formula I need to be using?

thx

2. You probably remember the sum formula for the first natural numbers

$\frac{n(n+1)}{2}$ then in your example for calculating the sum of numbers between x and y we get:

$S(x,y) \, = \, \frac{x(x+1)}{2} - \frac{y(y+1)}{2} \qquad x>y$

3. so with this formula is it calculating like

201 + 202.... +299
or
200+201... +300

thx

4. Seems like i made some slight mistake in my previous solution, the correct should be

$S(x,y) \, = \, \frac{x(x+1)}{2} \, - \, \frac{y(y-1)}{2} \qquad x>y$

Lets say S(204,200) this should be equal to

200 + 201 + 202 + 203 + 204 = 1010

Which indeed this formula gives us.

S(300,200)=25250

5. fantastic, so my program is outputting the correct answer! thx for the help much appreciated.

I do have another question or need another formula, I would like to remove the mutiples of 7.

from what I can remember this may have something to do with geometric or was it arithmatic sequences.

so the first multiples would be 203, 210, 217
and the difference between them is obviously 7,

so now I need to find the sum of the multiples of 7 between 2 numbers, so I can subtract it from my total of 25250

6. Originally Posted by KavX
fantastic, so my program is outputting the correct answer! thx for the help much appreciated.

I do have another question or need another formula, I would like to remove the mutiples of 7.

from what I can remember this may have something to do with geometric or was it arithmatic sequences.

so the first multiples would be 203, 210, 217
and the difference between them is obviously 7,

so now I need to find the sum of the multiples of 7 between 2 numbers, so I can subtract it from my total of 25250
The multiples of 7 would range from 203 (7*29) through 294 (7*42). So, this sum would be

203 + 210 + 217 + ... + 294

which is the same as

7*29 + 7*30 + 7*31 + ... + 7*42

We can factor the 7 out, thus:

7*(29 + 30 + 31 + ... + 42)

So, if you can find the sum of the numbers between 29 and 42, and multiply that by 7, you will have calculated the sum of all the multiples of 7 between 200 and 300.

7. thx for the help again, just to double check if im doing this right

i got 468 when finding the sum between those 2 numbers, after multiplying by 7 i got 3276

8. $\sum\limits_{n = y}^m {7n} = - \frac{{7\left( {y - x + 1} \right)\left( {y + x} \right)}}{2}$

$S(x,y) = 25250 + \frac{{7\left( {y - x + 1} \right)\left( {y + x} \right)}}{2} \qquad x>y$

Enjoy

9. using your formula Nebuchadnezzar, i get 3479 as the sum of the multiplys of 7

so 25250 -3479 = 21771

are those correct?
thx for the help

10. Originally Posted by KavX
thx for the help again, just to double check if im doing this right

$\frac{29+42}{2} \cdot 14 = 497$