PROC put (INT CONST a): IF get column + int length > xsize THEN line FI; put (text (a, int length)) ENDPROC put; sieve: LET limit = 1000; calculate int length; prepare the sieve; start with the first odd prime; WHILE another prime to sieve REP cross out all multiples; take the next prime ENDREP; print the sieve; how long. calculate int length: INT VAR lgth :: 1; WHILE 10 ** lgth < limit REP lgth INCR 1 ENDREP; INT CONST int length :: lgth + 2. prepare the sieve: ROW limit BOOL VAR is prime; put ("Sieving for primes <"); put (limit); line (2); put (2); call all odd numbers prime. call all odd numbers prime: INT VAR i; FOR i FROM 1 UPTO limit REP is prime [i] := i MOD 2 = 1 ENDREP. start with the first odd prime: INT VAR prime :: 3. another prime to sieve: prime * prime <= limit. cross out all multiples: put (prime); INT VAR multiple :: prime * prime; WHILE multiple <= limit REP is prime [multiple] := false; multiple INCR prime ENDREP. take the next prime: REP prime INCR 2 UNTIL is prime [prime] ENDREP. print the sieve: FOR i FROM prime UPTO limit REP IF is prime [i] THEN put (i) FI ENDREP. how long: line (2); put ("Time="); put (exectime); put (" sec.").