Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2005-05-11 14:08:09

sujit_pal@comcast.net
Member
Registered: 2005-05-11
Posts: 1

Sum of positive integers 0 to N

I am looking for different ways to answer this problem?

Want to find the sum of positive integers from 0 to N.

For example if N = 5 then

SUM = 0+1+2+3+4+5.

How do I solve if N = 1000

???

I found some interesting ways but looking for more ways to do it.

Sujit

Offline

#2 2005-05-11 18:39:56

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sum of positive integers 0 to N

Off the top of my head, you can do it with one multiplication. Middle-Value times N.

If N=5 then SUM = 1+2+3+4+5 = 15, using my idea the middle is 3, and 3 x 5 = 15
If N=6 then SUM = 1+2+3+4+5+6 = 21, using my idea the middle is 3.5 (half-way between 3 and 4) , and 3.5 x 6 = 21

This could be generalized as (Stt+End)/2 * (End-Stt+1)
where Stt=1 and End=N for your needs.

Let us try this one:

3+4+5+6=18
Using (Stt+End)/2 * (End-Stt+1): (3+6)/2 * (6-3+1) = 4.5 * 4 = 18

For your N=1000 case we would have (1+1000)/2 * (1000-1+1) = 500.5 * 1000 = 500,500

TADA !


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#3 2005-05-13 06:34:31

Milos
Member
Registered: 2005-05-06
Posts: 44

Re: Sum of positive integers 0 to N

I have learned this formula before. It is connected with mathematical induction. German mathematician Gauss, when he was 7 years old, thought of this formula. His teacher told students to find the sum of numbers, starting from 1 to 100. He thought that students won't finish it in next 30 minutes, but Gauss did. n(n+1)/2 where n is the last number.
This formula can be generalised so you can start from any number you like that belongs to N:
since n(n+1)/2 is when you start from  1, we will subtract the sum that needs to be subtracted:
if you are starting from 3 you will subtract from the main formula, 1+2. So let's write it:
n(n+1)/2 - x(x+1)/2
x=number below the one you are starting from
st= starting number
n(n+1)/2 - (st-1)(st-1+1)/2= [n(n+1)-st(st-1)]/2=[n^2+n-st^2+st]/2=[(n-st)(n+st)+n+st]/2=(n+st)(n-st+1)/2 -formula that administrator has mentioned
You also have formula for:
n e N   1^2+2^2+3^2.......n^2= n(n+1)(2n+1)/6

Offline

Board footer

Powered by FluxBB