Rewritten from the ground up in C++ with stability and performance improvements
Feature | Primer++ | Primer (Python) |
---|---|---|
Speed | Fast | Slow |
CPU Architecture | 32/64-bit | Same as Python install |
OS Compatability | Windows, Linux | All Python 3.6+ supported OSs |
Cross-compatiblity with other versions of Primer | ✅ | ✅ |
Multi-threaded | ❌ | ❌ |
Automatic updates (Windows) | ❌ | ✅ |
Automatic old (pre 1.2.0 ) config migration *1 |
❌ | ✅ |
Automatic config generation | ✅ | ✅ |
Console Window Title Support (Windows) *2 | ✅ | ✅ |
Generate prime numbers *3 | ✅ | ✅ |
Save prime numbers to a file *4 | ✅ | ✅ |
Keep track of generation statistics | ✅ | ✅ |
Generation statistic: Total Calculations | ✅ | ✅ |
Generation statistic: Prime numbers found | ✅ | ✅ |
Generation statistic: Latest prime found | ✅ | ✅ |
Save generation stats to a config *5 | ✅ | ✅ |
Pretty print config (easier to read & edit) *6 | ✅ | ❌ |
Load generation stats from the config on start *7 | ✅ | ✅ |
Language | C++ (GCC 8.1.0) | Python 3.6+ |
Created | 7th May 2020 | 26th November 2019 |
Build Success (master) | ||
Download Requirements | Windows, Linux | Python 3.6+ |
Direct download links |
-
If you're upgrading to Primer++ from Primer (Python)
1.1.0
or older, please run Primer (Python)1.2.0
(or newer) to automatically migrate your old config (Primer.config
) toPrimer_config.json
. -
Primer will display the current number being prime-tested, and how long it has been since the last prime was found in the console window title (when it has taken
more than 20 seconds to find a new prime
. This is to prevent Primer from slowing down early on when calculating small primes) -
To calculate primes, Primer will try to divide the test number between numbers 2-itself.
Test_number = 7 7 / 3 != whole number 7 / 4 != whole number 7 / 5 != whole number 7 / 6 != whole number Test_number must be prime! Test_number += 2 Test_number: 9 9 / 3 == whole number Test number is not prime!
-
Primer will save the prime numbers it finds to
Primer.txt
(each prime on a new line) -
Primer will save generation statistics to
Primer_config.json
(as soon as the statistics are updated) -
Pretty printed config has all values expanded, and makes it much easier to read.
Pretty Print:
{ "debugging": { "Force Unix": "False" }, "statistics": { "Latest Prime": 0, "Primes Found": 0, "Total Calculations": 0 } }
Non-pretty Print:
{"debugging": {"Force Unix": "False"}, "statistics": {"Latest Prime": 0, "Primes Found": 0, "Total Calculations": 0}}
The reason why Primer (Python) doesn't pretty print is because I haven't found an efficient way to do so.
-
Loading generation statistics (
Primer_config.json
) on start means that when you close the application, starting it up again will return to the state it was in when it closed. This allows you to pickup where you left off.
MacOS pre-compiled binary unavailable due to complications with statically linking Primer++.hpp
and json.hpp
with Primer++.cpp
. Because of this, it is currently only possible to run Primer++ on MacOS by building it yourself with the build instructions below.
- Follow Prerequisits steps 2-4 on the Visual Studio Code documentation to install MinGW
- Clone the repository (or place
Primer++.cpp
,Primer++.hpp
,Primer++_resource.o
(Primer++_x32_resource.o
),json.hpp
,makefile
andbuild.bat
in the same directory) - 64-bit: Run
build.bat
(or open a terminal in that directory and runmingw32-make
) - 32-bit: Open a terminal in that directory and run
mingw32-make 32-bit=true
- Output executable:
Primer++.exe
(Primer++_32.exe
)
Build OSs Tested | GCC version (local) | Local Success | CI Success |
---|---|---|---|
Windows 10 (64-bit) | GCC 8.1.0 (MinGW) | ✅ (v1.2.2) |
- Clone the repository (or place
Primer++.cpp
,Primer++.hpp
,json.hpp
andmakefile
in the same directory) - Open a terminal in that directory and run
make
(or executeBuild.sh
) - Run Primer with
./Primer++
(or double-click the compiled executable in a file explorer) - Output executable:
Primer++
Build OSs Tested | GCC version (local) | Local Success | CI Success |
---|---|---|---|
MacOS Catalina 10.15.4 | Apple clang 11.0.3 | ✅ (v1.2.2) | |
Fedora 28 | GCC 8.3.1 | ✅ (v1.2.2) | Untested |
Ubuntu | Untested |
Common Build Errors | OS | How to fix them | Verified Fix |
---|---|---|---|
cannot find -lstdc++ |
Fedora | Run sudo yum install libstdc++-static |
✅ |
cannot find -lm |
Fedora | Run sudo yum install glibc-static |
✅ |
cannot find -lc |
Fedora | Run sudo yum install glibc-static |
✅ |
Other Errors | All | Try removing --static from the build command |
Written in C++ with (MinGW) GCC 8.1.0 on Windows 10
On the 25th of November 2019 I was watching a video about the importance of prime numbers for encryption. This spiked my interest, and after learning how critical prime numbers are for the world we live in, I really wanted to start generating my own.
The intention wasn't to find the next biggest prime number, Python is definitely the wrong language to use for that purpose, but instead just to see if I could continuously generate prime numbers, store them all to a file, and continue where I left off next time I start the script.
I immediately made a head start on getting the basic generation working, and the following morning created a GitHub repository for the project and pushed what I had created so far.
Its non-destructive nature suprised my teachers, and they were all rather impressed how Primer performed and the statistics it provided.
Primer was re-written from the ground up in C++ (5th - 7th May 2020) with stability and performance improvements. This was my first real experience with the C++ language, and I really enjoyed it.
Written in Python 3.8 on Windows 10