--- title: "Prime Numbers" id: 76573 type: "computer_media" slug: "prime-numbers" url: "http://localhost/computer_media/prime-numbers/" markdown_url: "http://localhost/computer_media/prime-numbers.md" published_at: "2026-11-11T08:02:24+00:00" modified_at: "2026-11-11T08:02:24+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/11/prime-numbers-1.png" excerpt: "List every prime number below 1000 on a ZX80, using trial division by the odd numbers up to 31." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "ZX80" slug: "zx80" taxonomy: "post_tag" url: "http://localhost/tag/zx80/" model: - name: "Sinclair ZX80" slug: "zx80" taxonomy: "model" url: "http://localhost/model/zx80/" indiv: - name: "Phyllis Richmond" slug: "phyllis-richmond" taxonomy: "indiv" url: "http://localhost/indiv/phyllis-richmond/" genre: - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_type: "Program" programmers: - name: "Phyllis Richmond" slug: "phyllis-richmond" taxonomy: "indiv" url: "http://localhost/indiv/phyllis-richmond/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Prime%20Numbers%20%281981%29%28Richmond%2C%20Phyllis%29%28ZX80%29%28US%29%28Program%29.zip" mediadate: "1981" images: - url: "http://localhost/wp-content/uploads/2026/11/prime-numbers-1.png" article_media: - id: 19663 title: "Prime Numbers" type: "article" url: "http://localhost/article/prime-numbers/" media_type_tags: "Mathematics" license: false --- # Prime Numbers 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](https://timexsinclair.com/article/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 N ```