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


Groups > comp.lang.forth > #59706

Rosetta: Ludic numbers

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject Rosetta: Ludic numbers
Date 2017-05-22 03:23 +0000
Organization Aioe.org NNTP Server
Message-ID <oftliv$540$1@gioia.aioe.org> (permalink)

Show all headers | View raw


> Ludic numbers are related to prime numbers as they are
> generated by a sieve quite like the Sieve of Eratosthenes is
> used to generate prime numbers.
> 
> The first ludic number is 1.
> 
> To generate succeeding ludic numbers create an array of
> increasing integers starting from 2.
> 
> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...
> 
> (Loop) 
> 
> Take the first member of the resultant array as the next ludic
> number 2.
> 
> Remove every 2nd indexed item from the array (including the
> first).
> 
> (Unrolling a few loops...)
> 
> Take the first member of the resultant array as the next ludic
> number 3.
> 
> Remove every 3rd indexed item from the array (including the
> first).
> 
> ...
> 
> Take the first member of the current array as the next ludic number L.
> 
> Remove every Lth indexed item from the array (including the first).
> 
> ...

> Task
> Generate and show here the first 25 ludic numbers.
> How many ludic numbers are there less than or equal to 1000?
> Show the 2000..2005th ludic numbers.


(use lazy-lists)

(define (sift Lst)
  (if (= 1 (First Lst))
    (Rest Lst)
    (Map cdr
      (Remp (lambda(k) (= 0 (modulo (car k) (First Lst))))
            (Map cons (Cardinals) Lst)))))

(define ludics
  (Map First (Iterate sift (Rest (Cardinals)))))

(List->list (Take 25 ludics))
 ===>
(1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107)

(Count-while (lambda(n) (< n 1000)) ludics)
 ===>
142

(List->list (Take 6 (Drop 1999 ludics)))
 ===>
(21475 21481 21487 21493 21503 21511)


In Forth?


-- 
Again, commenters focused on the double standard whereby Jews advocate
multiculturalism and immigration for Europe, but have Israel as an avowedly
Jewish state to fall back on....
theoccidentalobserver.net/2015/11/douglas-murrays-warning-to-the-jewish-community

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


Thread

Rosetta: Ludic numbers "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-22 03:23 +0000

csiph-web