This version of the program is slightly optimized compared to the Atari ST version it is based on...

- Code: Select all
`10 DIM a(255): LET k=2`

20 FOR n=2 TO 255/k

30 LET a(n*k)=1

40 NEXT n

50 FOR n=K+1 TO 255

60 IF a(n)=1 THEN GO TO 80

70 LET k=n: LET n=255

80 NEXT n

90 IF k < 128 THEN GO TO 20

This program seems to take about 8 seconds to run...

Afterwards the array a() will contain a '0' in all locations corresponding to a prime number.

I have not yet attempted a 16bit version...

For anyone wanting to get the numbers on the screen, add these lines to the program before running it:

- Code: Select all
`100 FOR n=1 TO 255: IF a(n)=0 THEN PRINT n`

110 NEXT n

Can this be optimized further?