I think this fixes the Plus/4 version, and the loops should be similar on the Apple II.

It has not been verified against other versions though.

Run time was 4.2 seconds.

20 K=0:T=0:P=0:I=0 30 SCNCLR 100 PRINT "Prime Number Generator" 110 INPUT "Upper Limit";N 120 eTime=TIME 130 T = (N-3)/2 140 DIM A(T+1) 160 FOR I=0 TO T:A(I)=1:NEXT I 200 FOR I=0 TO T 220 IF A(I)=1 THEN P=I+I+3:PRINT P;".";:K=I+P:GOTO 250 240 PRINT "..";:NEXT I:GOTO 330 250 IF K<=T THEN FOR K=K TO T STEP P:A(K)=0:NEXT K 260 NEXT I 330 eTime = (TIME - eTime)/60 340 PRINT 350 PRINT "Total: ";eTime 360 END

*edit*

I forgot, the Plus/4 supports ELSE. This is cleaner and if you remove the spaces from the loops it runs in 4.1 seconds.

I vaguely remember something about Commodore being faster if you leave the variable off of the NEXT statement, but I'm not messing with it.

200 FOR I=0 TO T 220 IF A(I)=1 THEN P=I+I+3:PRINT P;".";:K=I+P:ELSE PRINT "..";:NEXT I:GOTO 330 250 IF K<=T THEN FOR K=K TO T STEP P:A(K)=0:NEXT K 260 NEXT I

**Edited by JamesD, Wed Nov 22, 2017 2:47 AM.**