1000 REM PRIME NUMBER GENERATION USING SIEVE OF ERATOSTHENES
1010 REM THIS PROGRAM GENERATES PRIME NUMBERS UP TO A GIVEN LIMIT
1020 REM INITIALIZATION
1030 SIZE = 8190
1040 DIM FLAGS(8191)
1050 PRINT "THIS PROGRAM GENERATES PRIME NUMBERS UP TO 8190 USING"
1060 PRINT "THE SIEVE OF ERATOSTHENES. PRESS ENTER TO BEGIN."
1070 INPUT "", DUMMY$
1080 PRINT "ONLY 1 ITERATION"
1090 COUNT = 0
1100 FOR I = 0 TO SIZE
1110 FLAGS(I) = 1
1120 NEXT I
1130 FOR I = 0 TO SIZE
1140 IF FLAGS(I) = 0 THEN GOTO 1230
1150 PRIME = I + I + 3
1160 K = I + PRIME
1170 IF K > SIZE THEN GOTO 1210
1180 FLAGS(K) = 0
1190 K = K + PRIME
1200 GOTO 1170
1210 COUNT = COUNT + 1
1220 FLAGS(I) = 1
1230 IF I MOD 1000 = 0 THEN PRINT ".";
1240 NEXT I
1250 PRINT
1260 PRINT "COUNT "; COUNT; " PRIMES"
1270 PRINT "*** END OF PROGRAM ***"
1280 END
