# prime-div

This tool was originally written to display any natural number as a sum of prime numbers, but it is also a efficient tool to calculate prime numbers.

## Prime number calculation

The known list of prime numbers are saved in `prime.txt` in string representation, one prime per line. The program loads this file, begins at the next larger integer, and checks if it is divisible by any of the known primes. If not it is added to the list. Repeat with the next larger integer, and so on.

The check is performed in parallel using multiple striding goroutines.

## Usage

`prime-div [flags] <number>`

Flags:

- `-p`: Calculate and save prime list up to the given number. If not given, the given number will be split into primes. If not all necessary prime numbers are in the list, the necessary primes will be calculated before, but they will not be saved.
- `-d`: Don't load `prime.txt`. This results in calculation starting from zero.
- `-r n`: Use *n* routines to calculate. 0 = number of available CPU cores. This is the default.
