Hi, Mango

True, you save a few lines of code by that GOTO, but if you insert them as I have done below, I think the program is a bit easier to follow and it doesn't take any longer to run.

Mac

P.S. Both versions don't list "2", the first prime number. LOL.

DIM Max AS INTEGER: Max = 3500

DIM SmallPrimes(Max) AS INTEGER

CLS

PRINT "This program sticks primes in an array then prints 'em"

' set initial values

DIM a AS INTEGER: a = 0

SmallPrimes(1) = 3

DIM Next1 AS INTEGER: Next1 = 5

DIM Count AS INTEGER: Count = 1

DIM SQroot AS INTEGER

' find first 3500 primes and put them in array, smallprimes()

' use 2-byte integer for small primes

DO WHILE Count < Max

SQroot = SQR(Next1)

Prime = -1: ' Assume prime number

DO

a = a + 1

IF Next1 MOD SmallPrimes(a) = 0 THEN Prime = 0: EXIT DO

LOOP WHILE SQroot > SmallPrimes(a)

IF Prime THEN Count = Count + 1: SmallPrimes(Count) = Next1

Next1 = Next1 + 2

a = 0

LOOP

FOR z = 1 TO 20: : PRINT SmallPrimes(z); : NEXT z: PRINT

FOR z = Max - 20 TO Max: PRINT SmallPrimes(z); : NEXT z: PRINT

SYSTEM