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


Groups > comp.lang.forth > #59478

Re: Rosetta: Babbage problem

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject Re: Rosetta: Babbage problem
Date 2017-05-18 09:29 +0000
Organization Aioe.org NNTP Server
Message-ID <ofjpi3$1uk7$1@gioia.aioe.org> (permalink)
References <oerulu$1tuq$1@gioia.aioe.org> <ofjp60$1tv2$1@gioia.aioe.org>

Show all headers | View raw


On 5/18/2017, Robert L. wrote:

> On 5/9/2017, Robert L. wrote:
> 
> > > Charles Babbage, looking ahead to the sorts of problems his
> > > Analytical Engine would be able to solve, gave this example:
> > > 
> > > What is the smallest positive integer whose square ends in the
> > > digits 269,696? -- Babbage, letter to Lord Bowden, 1837; see
> > > Hollingdale and Tootill, Electronic Computers, second edition,
> > > 1970, p. 125.
> > > 
> > > He thought the answer might be 99,736, whose square is
> > > 9,947,269,696; but he couldn't be certain.
> > > 
> > > Task
> > > 
> > > The task is to find out if Babbage had the right answer -- and
> > > to do so, as far as your language allows it, in code that
> > > Babbage himself would have been able to read and understand.
> > > 
> > > For these purposes, Charles Babbage may be taken to be an
> > > intelligent person, familiar with mathematics and with the
> > > idea of a computer, who has never programmed--in fact, who has
> > > never so much as seen a single line of code.
> > > 
> > > Motivation
> > > 
> > > The aim of the task is to write a program that is sufficiently
> > > clear and well-documented for such a person to be able to read
> > > it and be confident that it does indeed solve the specified
> > > problem.
> > 
> > 
> > (use srfi-121)
> > 
> > ;; Create function that accepts a number and returns
> > ;; true if, only if, it satisfies the requirements.
> > (define (good? n) (equal? 269696 (modulo (* n n) 1000000)))
> > 
> > ;; A generator for the natural numbers (1,2,3,4 ...).
> > ;; Each time it is called, it yields the next number.
> > (define generate-naturals (make-range-generator 1))
> > 
> > (generator-find good? generate-naturals)
> > 
> >  ===>
> > 25264
> > 
> > -----
> > 
> > (use lazy-lists)
> > 
> > (define (good? n) (equal? 269696 (modulo (* n n) 1000000)))
> > 
> > (First (Filter good? (Cardinals)))
> > 
> >  ===>
> > 25264
> > 
> > 
> > In Forth?
> 
> (let go ((i 0)) (if (= 269696 (modulo (* i i) 1000000)) i (go (+ 1 i))))
>  ===>
> 25264

(do ((i 0 (+ 1 i))) ((= 269696 (modulo (* i i) 1000000)) i))
 ===>
25264

-- 
For two years ... he was held in solitary confinement in the Toronto West
Detention Centre....  [A] court in Mannheim sentenced him to five years
imprisonment for the crime of "popular incitement" under Germany's notorious
"Holocaust denial" statute.  www.revisionists.com/revisionists/zundel.html

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


Thread

Rosetta: Babbage problem "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-09 08:29 +0000
  Re: Rosetta: Babbage problem mhx@iae.nl - 2017-05-09 12:58 -0700
    Re: Rosetta: Babbage problem Paul Rubin <no.email@nospam.invalid> - 2017-05-09 20:43 -0700
      Re: Rosetta: Babbage problem Julian Fondren <julian.fondren@gmail.com> - 2017-05-09 23:43 -0700
        Re: Rosetta: Babbage problem Lars Brinkhoff <lars.spam@nocrew.org> - 2017-05-10 09:06 +0200
          Re: Rosetta: Babbage problem Julian Fondren <julian.fondren@gmail.com> - 2017-05-10 00:27 -0700
            Re: Rosetta: Babbage problem Lars Brinkhoff <lars.spam@nocrew.org> - 2017-05-10 09:32 +0200
          Re: Rosetta: Babbage problem Paul Rubin <no.email@nospam.invalid> - 2017-05-10 00:59 -0700
            Re: Rosetta: Babbage problem Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-10 08:14 -0500
      Re: Rosetta: Babbage problem mhx@iae.nl - 2017-05-10 02:59 -0700
        Re: Rosetta: Babbage problem Bruno Gauthier <bgauthier@free.fr> - 2017-05-15 12:25 +0200
          Re: Rosetta: Babbage problem mhx@iae.nl - 2017-05-15 04:17 -0700
            Re: Rosetta: Babbage problem Bruno Gauthier <bgauthier@free.fr> - 2017-05-15 13:48 +0200
              Re: Rosetta: Babbage problem Julian Fondren <julian.fondren@gmail.com> - 2017-05-15 04:56 -0700
                Re: Rosetta: Babbage problem Bruno Gauthier <bgauthier@free.fr> - 2017-05-15 16:33 +0200
              Re: Rosetta: Babbage problem mhx@iae.nl - 2017-05-15 10:53 -0700
              Re: Rosetta: Babbage problem albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-15 21:39 +0200
  Re: Rosetta: Babbage problem "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-18 09:23 +0000
    Re: Rosetta: Babbage problem "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-18 09:29 +0000

csiph-web