Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v2 n9 (Volume 2, Issue 9)
Date: September 1981
Pages: 11
Numbers that cannot be divided evenly by numbers other than 1 or themselves are termed prime. This program lists all prime numbers between 1 and 1000.
Type RUN (NL), and the screen will go blank as the ZX80 figures out the numbers. The program takes a while to finish; press BREAK to list what numbers the computer has found so far.
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 N
Syntactic Sum: 16764, 4K
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.