Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #53264

Re: A function to return the sum of the numbers less than n

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: A function to return the sum of the numbers less than n
Date 2016-12-10 17:08 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016Dec10.180840@mips.complang.tuwien.ac.at> (permalink)
References <o2gmg2$1gk5$1@gioia.aioe.org> <d2bc014f-916d-4f94-9459-0718e388da92@googlegroups.com> <2016Dec10.134851@mips.complang.tuwien.ac.at> <9be47bcf-7031-4075-a110-c97718ce65a0@googlegroups.com>

Show all headers | View raw


Julian Fondren <julian.fondren@gmail.com> writes:
>On Saturday, December 10, 2016 at 6:58:25 AM UTC-6, Anton Ertl wrote:
>> # /usr/bin/time gforth -e ": sum ( u1 -- u2 ) dup 1- * 2/ ; 1000000000 sum . bye"
>> 499999999500000000 0.00user 0.00system 0:00.00elapsed 66%CPU (0avgtext+0avgdata 2780maxresident)k
>> 0inputs+0outputs (0major+334minor)pagefaults 0swaps
>> 
>> (supposedly discovered by Gauss when he was 9 years old).
>> 
>
>Woops. I was going to credit Euler.

I took the opportunity to look this up in Wikipedia, and while the
story about Gauss (re)discovering this as a child is well known, Euler
already considered the infinite case
<https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF#History>,
and I guess the finite case was considered trivial by him.
<https://en.wikipedia.org/wiki/Triangular_number> says:

|some find it likely that its origin goes back to the Pythagoreans 5th
|century BC.[2] The two formulae were described by the Irish monk
|Dicuil in about 816 in his Computus.

>Given a "keep the kids silent for a bit"
>makework problem

That was one motivation, the other was to make the pupils exercise
their calculation skills.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2016: http://www.euroforth.org/ef16/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A function to return the sum of the numbers less than n "Robert L." <No_spamming@noWhere_7073.org> - 2016-12-10 10:47 +0000
  Re: A function to return the sum of the numbers less than n Julian Fondren <julian.fondren@gmail.com> - 2016-12-10 03:19 -0800
    Re: A function to return the sum of the numbers less than n foxaudioresearch@gmail.com - 2016-12-10 03:58 -0800
    Re: A function to return the sum of the numbers less than n anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-10 12:48 +0000
      Re: A function to return the sum of the numbers less than n Julian Fondren <julian.fondren@gmail.com> - 2016-12-10 05:29 -0800
        Re: A function to return the sum of the numbers less than n pahihu <pahihu@gmail.com> - 2016-12-10 06:37 -0800
        Re: A function to return the sum of the numbers less than n anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-10 17:08 +0000
  Re: A function to return the sum of the numbers less than n jean-pierre@buechi-schmitt.ch - 2016-12-10 07:04 -0800
    Re: A function to return the sum of the numbers less than n awegel@arcor.de (Alexander Wegel) - 2016-12-10 22:59 +0100

csiph-web