File:  [gforth] / gforth / sieve.fs
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Fri Feb 11 16:30:48 1994 UTC (27 years, 9 months ago) by anton
Branches: no-vendor
CVS tags: alpha
The GNU Forth Project

    1: #! /usr/stud/paysan/bin/forth
    2: 
    3: $1FFE Constant 8190
    4: Create flags 8190 allot
    5: flags 8190 + AConstant eflag
    6: 
    7: : PRIMES  ( -- n )  FLAGS 8190 1 FILL  0 3  EFLAG FLAGS
    8:   DO   I C@
    9:        IF  DUP I + DUP EFLAG <
   10:            IF    EFLAG SWAP
   11:                  DO  0 I C! DUP  +LOOP
   12:            ELSE  DROP  THEN  >R 1+ R>
   13:            THEN  2 +
   14:        LOOP  DROP ;
   15: 
   16: : BENCHMARK  0 &100 0 DO  PRIMES NIP  LOOP ;
   17: &10 BASE !
   18: BENCHMARK .
   19: BYE
   20: \ HPPA/720, 50 MHz: user 3.90s

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