DIM Flags(8190) AS SHORT
DIM Iter AS SHORT
DIM I AS SHORT
DIM Count AS SHORT
DIM K AS SHORT
DIM Prime AS SHORT
PRINT "Sieve - 10 iterations"
FOR I = 0 TO 8190
Flags(I) = 1
NEXT I
DIM M AS QMEMORYSTREAM
M.SaveArray(Flags(0), 8191)
FOR Iter = 1 TO 10
Count = 0
T! = TIMER
FOR I = 0 TO 8190
IF Flags(I) = 1 THEN
Prime = I + I
Prime = Prime + 3
K = I + Prime
WHILE K <= 8190
Flags(K) = 0
K = K + Prime
WEND
Count = Count + 1
END IF
NEXT I
PRINT "Iteration "; Iter; ": took "; TIMER - T!; " seconds."
M.Position = 0
M.LoadArray(Flags(0), 8191)
NEXT Iter
|