( 2000 feb 17 : AH after generations of mangling, ) ( restored from 1983 jan BYTE, including layout. ) ( 2005 apr 9: is now fully original ) ( Note that VARIABLE no longer takes a parameter in ) ( ISO-forth and that VARIABLE cannot be portably ) ( used to create arrays in this way. ) ( Also note that the printing must be removed for ) ( a reasonable benchmark on modern machines, ) ( lest it would become an I/O benchmark. ) ( 2017 jul 5 : AH SIZE was 8190 , thanks Anton Ertl ) ( THE ORIGINAL ) ( Eratosthenes Sieve Prime Number Program in Forth ) ( This program does ONLY iteration) ( Multiply times by 10 for comparison) 8190 CONSTANT SIZE 0 VARIABLE FLAGS SIZE ALLOT : DO-PRIME FLAGS SIZE 1 FILL ( SET ARRAY ) 0 ( 0 COUNT ) SIZE 0 DO FLAGS I + C@ IF I DUP + 3 + DUP I + BEGIN DUP SIZE < WHILE 0 OVER FLAGS + C! OVER + REPEAT DROP DROP 1+ THEN LOOP . ." PRIMES" ; ( END OF THE ORIGINAL ) ( For todays fast machines you need: ) : PRIMES ( iterations -- ) 0 DO DROP DO-PRIME LOOP ;