Just incase anyone cares, I thought I''d post the listing of a program to produce a list of primes using the sieve of eratosthenes. Because this program was written to work on a BBC microcomputer (which IIRC had a clock speed of about 2mhz) it should run very fast on a modern 1+ GHz machine.
The code is in BASIC btw - I can''t really be bothered to translate it, it''s not exactly difficult to understand.
10 DIM P(2000)20 REM SET ARRAY ELEMENTS EQUAL TO ONE ( CREATE LIST )30 MAT P = CON40 PRINT "PRIMES FROM 2 - 2000"50 LET F = SQR(2000)60 FOR I = 2 TO 200070 IF P(I) = 0 THEN GOTO 14080 PRINT I;90 IF I > F THEN GOTO 140100 REM REMOVE MULTIPLES FROM LIST ( SET TO ZERO )110 FOR J = I TO 2000 STEP I120 LET P(J) = 0130 NEXT J140 NEXT I150 END
Also, remember that each line has a line number so that goto''s work etc.
John B