Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/examples/bench/primes.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


( primes.f              Simple Prime number generator )

variable lines
5 constant wide

: ?cr lines @ = if cr 0 lines ! else 1 lines +! then ;

: ?prime        ( n1 -- f1 )
                dup 2
                do      dup i mod 0=
                        if      0= leave
                        then
                loop    ;

: .primes       ( -- )
                2 lines !
                cr 1 wide .r 3 wide .r
                512 4
                do      i ?prime
                        if i wide .r 10 ?cr
                        then
                loop   cr ;

.primes


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].