Back in the very early 1980s I used AceForth on a Tandy Xenix to write an autoparts hardware application for a client.
A couple weeks ago I installed gforth and began playing with it. I wrote a program that computes the number of primes from 0 to some given number.
In a Konsole running gforth I computed all the primes between 0 and 10,000,000. It took 23 seconds.
A couple weeks ago I installed gforth and began playing with it. I wrote a program that computes the number of primes from 0 to some given number.
In a Konsole running gforth I computed all the primes between 0 and 10,000,000. It took 23 seconds.
Code:
: PRIMES ( n - )
2 SWAP 2 . 3 . 5
DO DUP DUP * i <
IF 1+
THEN
1 OVER 1+ 3
DO J I MOD 0=
IF 1- LEAVE
THEN
2
+LOOP
IF I .
THEN
2
+LOOP
DROP ;


