Sum of Natural Numbers

I was working on some code today which dealt with numbers.

It was about doing a sum of numbers from 1 + 2 + 3 + 4 + …. + N.

I am pretty sure this is known, but here is how it goes:

  • Odd numbers:

Suppose we are doing a sum of numbers 1 to N where N is an odd number.

Lets consider N to be number 5:

1 + 2 + 3 + 4 + 5 = 15

In the numbers above, 3 is in the center of the sequence, and 5 x 3 = 15. If N is 7 then 7 x 4 = 28 where 4 is at the center of the sequence.

But what if N is huge number like 12345. Finding the number at the center of the sequence is tough. When N was 5 the number at center of the sequence was 3, i.e. 5/2 + 1/2 = 2.5 + 0.5 = 3. This is also true for 7, 11, 13,… Therefore, when N is 12345:

12345/2 + 1/2 = 6173

So the sum of sequence 1 + 2 + 3 + 4 +….. + 12345 = 12345 x 6173 = 76205685.

i.e. For any given Number N, where N is odd, the sum of 1 to N is N x (N/2 + 1/2)

  • Even numbers:

Consider the same scenario when N is an even number. For eg:

1 + 2 + 3 + 4 + 5 + 6 = 21

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36

Here when N is 6, 21 = (6 x (6/2)) + (6/2).

i.e. For any given number N, where N is even, the sum of 1 to N is (N x (N/2)) + (N/2)

All the above is just an observation, I dont have any proof (yet). It might exist already or I might have studied in school too, but dont remember now 🙂

Advertisements

One thought on “Sum of Natural Numbers

  1. Excellent observation and its absolutely true !. The sum of first n natural numbers as we already know is n(n+1)/ 2 . Your expressions for both even and odd natural numbers reduce to the same and therefore its correct 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s