Tool to calculate prime numbers and represent any given natural number as a sum of prime numbers
Go to file
2024-10-03 12:28:33 +02:00
.gitignore Initial commit 2024-09-30 00:34:45 +02:00
go.mod feat(io): Implemented zstd-compressed msgpack format 2024-10-03 12:28:33 +02:00
go.sum feat(io): Implemented zstd-compressed msgpack format 2024-10-03 12:28:33 +02:00
io.go feat(io): Implemented zstd-compressed msgpack format 2024-10-03 12:28:33 +02:00
main.go feat(io): Implemented zstd-compressed msgpack format 2024-10-03 12:28:33 +02:00
prime.txt change(prime): Calculated up to 225,000,000 2024-10-01 14:42:21 +02:00
README.md feat(generatePrimes): Added option to override number of routines 2024-09-30 19:43:46 +02:00
tensor.go change(generatePrimes): Now skipping over even numbers 2024-10-03 00:51:21 +02:00

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.