Documentation ¶
Index ¶
- func Factorize(n int64) map[int64]int64
- func Generate(limit int) []int
- func GenerateChannel(ch chan<- int)
- func MillerRabinDeterministic(num int64) (bool, error)
- func MillerRabinProbabilistic(num, rounds int64) (bool, error)
- func MillerRandomTest(num int64) (bool, error)
- func MillerTest(num, witness int64) (bool, error)
- func MillerTestMultiple(num int64, witnesses ...int64) (bool, error)
- func OptimizedTrialDivision(n int64) bool
- func Sieve(in <-chan int, out chan<- int, prime int)
- func TrialDivision(n int64) bool
- func Twin(n int) (int, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Factorize ¶
Factorize is a function that computes the exponents of each prime in the prime factorization of n
func GenerateChannel ¶
func GenerateChannel(ch chan<- int)
Generate generates the sequence of integers starting at 2 and sends it to the channel `ch`
func MillerRabinDeterministic ¶
MillerRabinDeterministic is a Deterministic version of the Miller-Rabin test, which returns correct results for all valid int64 numbers.
func MillerRabinProbabilistic ¶
MillerRabinProbabilistic is a probabilistic test for primality of an integer based of the algorithm devised by Miller and Rabin.
func MillerRandomTest ¶
MillerRandomTest This is the intermediate step that repeats within the miller rabin primality test for better probabilitic chances of receiving the correct result with random witnesses.
func MillerTest ¶
MillerTest tests whether num is a strong probable prime to a witness. Formally: a^d ≡ 1 (mod n) or a^(2^r * d) ≡ -1 (mod n), 0 <= r <= s
func MillerTestMultiple ¶
MillerTestMultiple is like MillerTest but runs the test for multiple witnesses.
func OptimizedTrialDivision ¶
OptimizedTrialDivision checks primality of an integer using an optimized trial division method. The optimizations include not checking divisibility by the even numbers and only checking up to the square root of the given number.
func Sieve ¶
Sieve Sieving the numbers that are not prime from the channel - basically removing them from the channels
func TrialDivision ¶
TrialDivision tests whether a number is prime by trying to divide it by the numbers less than it.
Types ¶
This section is empty.