Skip to content

smcclennon/Primer

Repository files navigation

Primer++ logo

Primer++

Rewritten from the ground up in C++ with stability and performance improvements

build (Windows) build (MacOS) build (Linux) build (Python) Codacy Badge Language grade: C/C++ Language grade: Python Maintainability License FOSSA license Status GitHub release (latest by date including pre-releases) GitHub commits since latest release (by date) GitHub last commit Github download count HitCount

Features

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) build (C++) build (Python)
Download Requirements Windows, Linux Python 3.6+
Direct download links Download latest Primer++ release Download latest Primer (Python) release
  1. 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) to Primer_config.json.

  2. 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)

  3. 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!
  4. Primer will save the prime numbers it finds to Primer.txt (each prime on a new line)

  5. Primer will save generation statistics to Primer_config.json (as soon as the statistics are updated)

  6. 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.

  7. 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.


Downloads

Edition Primer++ Primer++ Primer++ Primer++ Primer
OS Windows Windows Linux MacOS Python-supported
Architecture 32-bit 64-bit 64-bit 64-bit Python Install
Filename Primer++_32.exe Primer++.exe Primer++ Primer++ Primer.py
CI Untested build (Windows) build (Linux) build (MacOS) build (Python)
Download Download latest Primer++ 32-bit Windows release Download latest Primer++ 64-bit Windows release Download latest Primer++ 64-bit Linux release Unavailable Download latest Primer (Python) release

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.


Building on Windows

Build OSs Tested GCC version (local) Local Success CI Success
Windows 10 (64-bit) GCC 8.1.0 (MinGW) ✅ (v1.2.2) build (Windows)

Building on Linux and MacOS

  • Clone the repository (or place Primer++.cpp, Primer++.hpp, json.hpp and makefile in the same directory)
  • Open a terminal in that directory and run make (or execute Build.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) build (MacOS)
Fedora 28 GCC 8.3.1 ✅ (v1.2.2) Untested
Ubuntu Untested build (Linux)

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


Story

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.


Primer Screenshots

Windows version Unix version

Written in Python 3.8 on Windows 10

Menu vector created by freepik - www.freepik.com