# openoffice-users mailing list archives

##### Site index · List index
Message view
Top
From "Dennis E. Hamilton" <dennis.hamil...@acm.org>
Subject RE: Calc: Easy way to do N+(N-1)+(N-2)+(N-3)..(N-N+1)
Date Sat, 22 Jun 2013 17:17:33 GMT
```Yes, the proof is now taught in elementary school, as I recall.  It was the first one I ever
learned to do.

It clearly does work, with adjustment, for ranges starting with other than 1, and it works
with negative numbers too.  It also doesn't matter whether you are counting down or counting
up, because it is symmetrical as far as addition is concerned.

To go from m to n, assume m is not larger than n.  If not, simply interchange them since the
summation taken in either direction is the same.

Write down the numbers

m,   m+1,  ..., n-1, n
n,   n-1,  ..., m+1, m

Each of those rows lists the numbers to be added, but in reversed sequence, as Rob shows,
below.

Notice that each vertical pair adds up to precisely m+n.

Satisfy yourself that there are exactly n-m+1 pairs (the columns) like that.  Notice that
works for m=n  too.

So the sum of all the numbers (using both rows) is (n-m+1)*(m+n)

But that's double the sum of just one of the rows.  The sum of just one of those rows, either
one,
is (n-m+1)*(m+n)/2.  (The sum over both rows must be an even number so the division always
work.)

Notice that m=0 and m=1 fall out as having the same results.

- Dennis

PS: That's why there is no need for a special function in OpenFormula to accomplish this.
Gauss showed that it is not hard.  I once owned a book that had many simplified formulas
for series and summations.  It's probably still available from Dover Publications.  Or just
use Internet Search and find Wikipedia articles and YouTube videos about them.

PPS: In elementary school, our principal gave out a problem based on the story of the fellow
who was to be rewarded by a king and had asked for grains of wheat to be put on the squares
of a chess board (64 squares) with 1 on the first square, 2 on the second, 4 on the third,
etc., until the end.  In the story, the fellow was rewarded by beheading.  Our school principal
wanted to know how may grains of wheat would have been awarded.  Every software developer
should know the shortcut, that requires only doublings and one subtraction.  You never have
to add up all of the individual numbers, so the chance for error is significantly reduced.
I didn't figure that out, but the principal showed me when I took in my clumsy column of
numbers.  At that time, commercial computers were just coming out, so binary arithmetic was
not widely-known.

-----Original Message-----
From: Rob Weir [mailto:robweir@apache.org]
Sent: Saturday, June 22, 2013 07:54 AM
To: users@openoffice.apache.org
Subject: Re: Calc: Easy way to do N+(N-1)+(N-2)+(N-3)..(N-N+1)

On Fri, Jun 21, 2013 at 6:39 PM, Toki Kantoor <toki.kantoor@gmail.com> wrote:
> On 06/21/2013 06:37 PM, Brian Barker wrote:
>> Yes.  Sigma (1 to n) is n(n+1)/2.
>
> Thanks.
>
>>> If so, what is the formula, extension, or something?
>>
>> =Xn*(Xn+1)/2
>>
>> I trust this helps.
>
> It helps a lot.

Friedrich Gauss, when he was 10 years old, was in an arithmetic class
where the teacher gave them all the problem to sum the digits from 1
to 100.

Maybe the teacher had some other task he wanted to do, or wanted to
take a nap?  So he gave them this task to keep them busy.

Gauss figured this out in his head (the answer is 5050), by
discovering the above formula, and put down his slate, much angering
the teacher.

The key is to rearrange the calculation.  So instead of
1+2+3+4...+100, think of it as: (1+100) + (2+99) + (3+98) ... +
(49+52) + (50+51) = 101*50

Regards,

-Rob

> I wish I had book that contained functions and their formula, that
> somebody that never took a match course could understand.
>
> jonathon
> --
> LibreOffice in a Multi-Lingual Environment.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: users-help@openoffice.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org