MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / MillerTestMultiple

Function MillerTestMultiple

math/prime/millerrabintest.go:85–98  ·  view source on GitHub ↗

MillerTestMultiple is like MillerTest but runs the test for multiple witnesses.

(num int64, witnesses ...int64)

Source from the content-addressed store, hash-verified

83// MillerTestMultiple is like MillerTest but runs the test for multiple
84// witnesses.
85func MillerTestMultiple(num int64, witnesses ...int64) (bool, error) {
86 for _, witness := range witnesses {
87 prime, err := MillerTest(num, witness)
88 if err != nil {
89 return false, err
90 }
91
92 if !prime {
93 return false, nil
94 }
95 }
96
97 return true, nil
98}
99
100// MillerRabinProbabilistic is a probabilistic test for primality
101// of an integer based of the algorithm devised by Miller and Rabin.

Callers 1

MillerRabinDeterministicFunction · 0.85

Calls 1

MillerTestFunction · 0.85

Tested by

no test coverage detected