Last active
June 13, 2024 09:35
-
-
Save Comet1903/8bced6419aab9b0ac930e09fde231b57 to your computer and use it in GitHub Desktop.
Calculate primes in Basic 7.0 on Commodore 128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 010 count = 10 | |
| 020 dim primes(count) | |
| 030 primes(0) = 2 | |
| 040 prl = 1 | |
| 050 current = 3 | |
| 060 do while prl < count | |
| 070 for i=0 to prl-1 | |
| 071 if primes(i) * primes(i) > current then goto 100 | |
| 075 x = int(current/primes(i)) | |
| 077 x = x*primes(i) | |
| 080 if x = current then goto 120 | |
| 090 next i | |
| 100 primes(prl) = current | |
| 110 prl = prl + 1 | |
| 115 print current | |
| 120 current = current + 2 | |
| 150 loop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment