# Primes by Trial Division - Sinclair ZX-80 BASIC

20 August 2016

On the ZX-80, one must use LET for assignment, pause when the screen is "full", and do without either INTeger or MODulus! So this version must rely on the use of integer-only division results for calculating a remainder explicitly and use PRINT; so that all the results fit on the screen at once.

Trying to use FOR/NEXT as the Applesoft version did results in stack exhaustion after a handful of results. Since there is no other kind of loop available in ZX-80 BASIC, we must make do with only GO TO—one final peculiarity (though irrelevant) is the tokenization of GO TO, where other BASICs use GOTO.

10 DIM P(99) 20 LET C=2 30 LET F=0 40 PRINT C; 50 LET P(F)=C 60 IF F=99 THEN GO TO 160 70 LET F=F+1 80 LET C=C+1 90 LET I=0 100 LET R=C-(C/P(I))*P(I) 110 IF R=0 THEN LET I=F+1 120 IF I>F THEN GO TO 80 130 LET I=I+1 140 IF I=F THEN GO TO 40 150 GO TO 100 160 STOP