Prime Number Generator
A simple prime number generator, using the sieve of Erastothenes algorithm (complexity n log n). The implementation was originally written for my RC2014 and translated into Sharp BASIC in early 2021 – thanks, pandemic!
This means that unlike the RC2014 version, it is limited to scanning the first 255 whole numbers for primes due to the maximum length of an array allowed in SP-5025 BASIC. I’m currently putting together a version that will overcome this limitation.



If you’d like to run some of the programs I’ve archived on your own MZ-80K or emulator, you can find them in my Sharp MZ-80K github repository.
Funnily enough, after a “hello world” type program, the second or third program I wrote for the school’s one week in four share of a PDP8/E with 4k of memory was a prime number generator. I still have a copy on paper tape and a printout. Rather than a sieve, I used integer arithmetic to check all possible factors up to the square root. While this was slower than a sieve, I could set the start point at any integer up to the max integer and start running.
Tested this code in TinyBASIC/IoTBASIC (https://github.com/slviajero/tinybasic)
on a ESP32-Lite and it took 4.374 secs for the Prime-Number up to 16000 (max MEM used by DIM)
Very cool & fast 🙂
I also will test your 2nd Prime-genarator Version.
Good luck with the ongoing development of your IoT BASIC!