10 ' Sieve
20 s=100000
30 DIM flags(s+1)
40 s$=TIME$
50 FOR i=0 TO s
60     flags(i)=TRUE
70 NEXT i
80 IF s>=0 THEN flags(0)=FALSE
90 IF s>=1 THEN flags(1)=FALSE
100 p=2
110 IF flags(p) THEN
120     FOR i=p*p TO s STEP p
130         flags(i)=FALSE
140     NEXT i
150 END IF
160 IF p*p<=s THEN p=p+1:GOTO 110
170 count=0
180 n=0
190 FOR i=0 TO s
200     IF flags(i) THEN count=count+1:PRINT i,:n=n+1:IF n=8 THEN PRINT:n=0
210 NEXT i
220 PRINT
230 PRINT
240 PRINT "Start: ";s$
250 PRINT " Done: ";TIME$
260 PRINT
270 PRINT count;"primes" ' should be 9592 primes
280 PRINT
