Prime numbers are numbers that are only divisible by 1 and itself. For example, 2, 3, 5, 7... But what about the number 132598717? It can be difficult to tell whether large numbers like this are prime or not. We may even need to check many big numbers like this (someday, who knows). That's why this program finds all prime numbers in a range given a start and end value VERY QUICKLY.
The program makes use of practical ways to check if a number is prime.
For more information see the details.
On Linux it's easy to install compilers and build systems.
debian
sudo apt install build-essentialIt also easy install on macOS with Homebrew.
macOS with Homebrew
brew install gcc makeInstalling Windows is a bit harder. First, install MinGW. For later, research how to install MinGW.
Then install this requirements:
- mingw32-base
- mingw32-gcc-g++
- mingw32-pthreads-w32
I assume you set system variables. You can compile the program manually, but I recommend using a build system. To install make run this command:
mingw-get install mingw32-makeCompile the executable in the 'bin' folder with the 'release' command in the Makefile for Linux or macOS.
make releaseTo compile for Windows, run this command.
mingw32-make releaseTo run enter the bin folder and type...
cd bin
./fastprimefinderEnter the start number and end number on the screen that comes up. All prime numbers in the range you specify will be found and saved to the file. 3
Found 664,579 primes between 1 and 10,000,000.
| Platform | CPU | Time |
|---|---|---|
| macOS 13.3.1 | Apple M1 | ~ 0.10 s |
| Windows 11, version 23H2 | Intel Core i5-12450H | ~ 0.16 s |
| Windows 11, version 23H2 | Intel Core i7-1255U | ~ 0.17 s |
| Ubuntu 22.10 | Intel Core i5-2400 | ~ 2.50 s |
Thanks ChatGPT 🙂