Tool to calculate prime numbers and represent any given natural number as a sum of prime numbers
Go to file
datalore ac1a8b7039 change(generatePrimesCPU): Now aborting at half of candidate
Numbers larger than the half of a number are not able to divide a number
2024-10-03 01:13:34 +02:00
.gitignore Initial commit 2024-09-30 00:34:45 +02:00
go.mod feat(generatePrimes): Added tensorflow variant 2024-10-03 00:32:59 +02:00
go.sum feat(generatePrimes): Added tensorflow variant 2024-10-03 00:32:59 +02:00
main.go change(generatePrimesCPU): Now aborting at half of candidate 2024-10-03 01:13:34 +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.