File:  [gforth] / gforth / sieve.fs
Revision 1.4: download - view: text, annotated - select for diffs
Mon Dec 27 13:16:47 2010 UTC (6 years, 9 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Added files for OpenSuSE build service

#! /usr/bin/gforth

DECIMAL
: SECS TIME&DATE  2DROP DROP  60 * + 60 * + ;
CREATE FLAGS 8190 ALLOT
FLAGS 8190 + CONSTANT EFLAG

: PRIMES  ( -- n )  FLAGS 8190 1 FILL  0 3  EFLAG FLAGS
  DO   I C@
       IF  DUP I + DUP EFLAG <
           IF    EFLAG SWAP
                 DO  0 I C! DUP  +LOOP
           ELSE  DROP  THEN  SWAP 1+ SWAP
           THEN  2 +
       LOOP  DROP ;

: BENCHMARK  0 100 0 DO  PRIMES NIP  LOOP ;
SECS BENCHMARK . SECS SWAP - CR . .( secs)

\ HPPA/720, 50 MHz: user 3.90s

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>