### Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-48) was last changed on 18-Jan-2021 16:05 by Stefan Haubenthal

This page was created on 04-Dec-2010 13:59 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

#### Difference between version 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 and 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

 At line 154 removed one line !! Bench PI(n) At line 156 removed 31 lines COPYRIGHT : Albert van der Horst FIG Chapter Holland This program and modified versions thereof may be distributed and used freely provided: 1. this copyright and a www reference to the original is kept 2. the following line states correctly either original or modified. This version is : modified for Forth83. The original version is available at http://home.hccnet.nl/a.w.m.van.der.horst/benchpin.frt DESCRIPTION: This (highly recursive) function calculates PI(n), i.e. the number of primes less or equal to n. It doesn't use a sieve, nor does it inspect numbers larger than the square root of n for primeness. It may be used for benchmarking, because it takes considerable time for large numbers. It is one of the few highly recursive algorithms that actually calculate something sensible. {{{ \ benchpin -- a highly recursiv function for PI(n) cas 20101204 : ?PRIME ( p -- flag ) >R R@ 4 U< IF R> DROP TRUE EXIT THEN R@ 1 AND 0= IF R> DROP FALSE EXIT THEN 2 3 BEGIN R@ OVER /MOD SWAP 0= IF R> DROP 2DROP FALSE EXIT THEN OVER < IF R> DROP DROP TRUE EXIT THEN 2+ REPEAT ; : DISMISS ( n1 p -- n2 ) >R R@ / DUP R@ < IF DROP R> 1 EXIT THEN DUP R> 2 ?DO I ?PRIME IF OVER I RECURSIVE - THEN LOOP SWAP DROP ; : PI ( n1 -- n2 ) DUP >R 1- R@ 2 / 1- - 3 BEGIN DUP DUP * R@ > 0= WHILE DUP ?PRIME IF CR DUP . ." is prime" R@ OVER DISMISS 1- SWAP >R - R> THEN 2+ REPEAT DROP R> DROP ; }}}
Version Date Modified Size Author Changes ... Change note
48 18-Jan-2021 16:05 0.163 kB Stefan Haubenthal to previous typo
47 01-Jan-2021 11:29 0.164 kB Carsten Strotmann to previous | to last
46 14-Dec-2014 22:43 36.466 kB Carsten Strotmann to previous | to last
45 14-Dec-2014 22:42 36.605 kB Carsten Strotmann to previous | to last
44 01-Nov-2014 18:28 36.568 kB Carsten Strotmann to previous | to last
43 01-Nov-2014 18:23 36.126 kB Carsten Strotmann to previous | to last
42 01-Nov-2014 18:22 36.126 kB Carsten Strotmann to previous | to last Results VCFB 2014
41 22-Sep-2014 21:43 34.05 kB Carsten Strotmann to previous | to last
« This page (revision-48) was last changed on 18-Jan-2021 16:05 by Stefan Haubenthal
G’day (anonymous guest) My Prefs
© 2010-2021 AtariWiki
All content in the Wiki is licensed under Creative Commons Share Alike License, unless otherwise noted.
JSPWiki v2.8.3