https://github.com/antosser/prime-number-calculator-cpp
Calculate prime numbers at insane speeds
https://github.com/antosser/prime-number-calculator-cpp
claculator cpp prime prime-numbers primes
Last synced: about 1 month ago
JSON representation
Calculate prime numbers at insane speeds
- Host: GitHub
- URL: https://github.com/antosser/prime-number-calculator-cpp
- Owner: Antosser
- Created: 2021-08-05T07:08:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-14T17:51:26.000Z (almost 3 years ago)
- Last Synced: 2025-02-07T18:51:24.850Z (3 months ago)
- Topics: claculator, cpp, prime, prime-numbers, primes
- Language: C++
- Homepage:
- Size: 48.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Antosser's really fast "Prime Number Calculator"
## Usage
1. Open commandline in the directory containing the executable
1. Execute the app with the following syntax:
```prime ( [-log] [-binin] [-binout] [-allout]) || <-todec> || <-tobin>```
1. Wait for the calculations to end## Parameters
* `-log` - Saves the progress and speed at any time (basically the console output) to ".log.csv" so it can be futherly opened in Google Sheets or Ms Exel
* `-binin` - Takes a compressed binary file as input (`{filename}.prime`)
* `-binout` - Outputs binary compressed file instead of decimal (`{filename}.prime`)
* `-allout` - Outputs both the compressed binary file and the decimal file
* `-tobin` - Converts the decimal file to compressed binary
* `-todec` - Converts the binary file to compressed decimal## How it works
```cpp
std::vector primes = {}; // Create a vector class
for (int i = 2; primes.size() < n; i++) { // Loop until vector's size is n
int root = sqrt(i) + 1;
for (int ci : primes) { // Loop trough every know prime
if (i % ci == 0)
goto brk; // Number is not prime
if (ci > root)
break; // Number is prime
}
primes.push_back(i);
brk:;
}// Print primes
for (auto i : primes)
std::cout << i << std::endl;
```