Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #59147
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Rosetta: Primorial numbers |
| Date | 2017-05-13 04:29 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <of622c$nqg$1@gioia.aioe.org> (permalink) |
> Primorial numbers are those formed by multiplying successive
> prime numbers.
>
> The primorial number series is:
>
> primorial(0) = 1 (by definition)
> primorial(1) = 2 (2)
> primorial(2) = 6 (2*3)
> primorial(3) = 30 (2*3*5)
> primorial(4) = 210 (2*3*5*7)
> primorial(5) = 2310 (2*3*5*7*11)
> primorial(6) = 30030 (2*3*5*7*11*13)
>
> Show the first ten primorial numbers (0 -- 9, inclusive).
>
> Show the length of primorial numbers whose index is:
> 10 100 1,000 10,000 and 100,000.
>
> Show the length of the one millionth primorial number (optional).
>
> Use exact integers, not approximations.
(use streams streams-math)
(use numbers)
(use srfi-42)
(define primorials (stream-scan * 1 prime-numbers-stream))
(define (primorial i)
(stream-fold * 1 (stream-take i prime-numbers-stream)))
(stream->list 10 primorials)
(do-ec
(:range i 1 6)
(:let j (expt 10 i))
(print "length of primorial " j ": "
(string-length (number->string (primorial j)))))
(1 2 6 30 210 2310 30030 510510 9699690 223092870)
length of primorial 10: 10
length of primorial 100: 220
length of primorial 1000: 3393
length of primorial 10000: 45337
length of primorial 100000: 563921
In Forth?
--
Goyim were born only to serve us. Without that, they have no place in the
world---only to serve the People of Israel.... They will work, they will plow,
they will reap. We will sit like an effendi and eat. --- Rabbi Ovadia Yosef
https://web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld/JewishNews/Article.aspx?id=191782
http://archive.org/download/DavidDuke_videos/TopRabbiExposesJewishRacism-cybsdwjezqi.ogv
Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread
Rosetta: Primorial numbers "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-13 04:29 +0000
csiph-web