Prints the prime numbers from 1 to 999. For each number the program tries the divisors from 3 to 31 (skipping the even ones), and prints the number when the quotient falls to 1 without an even division.
The ZX80 blanks its screen while it computes, so the list appears only when the program finishes; press BREAK to see the primes found so far.
Published in Syntax September 1981 (Prime Numbers).
Source Code
10 PRINT "PRIME NUMBERS"
20 FOR N=1 TO 999
30 FOR K=3 TO 31
40 LET Q=N/K
50 LET R=N-Q*K
60 IF Q=1 THEN GO TO 200
70 IF R=0 THEN GO TO 250
80 IF N=1 AND K=31 THEN GO TO 400
90 LET K=K+1
95 NEXT K
200 PRINT " ";N;
250 LET N=N+1
300 NEXT N
350 STOP
400 PRINT "1 2";
410 LET N=N+1
420 NEXT NNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
