Standard library / math/big

big.Int.ProbablyPrime()

Test probable primality using the configured number of Miller-Rabin rounds and a Baillie-PSW test. Not suitable for adversarially crafted candidates. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Int) ProbablyPrime(n int) bool

Parameters & Attributes

NameTypeDescription
nintNonnegative number of Miller-Rabin rounds.

Return Value

bool

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(big.NewInt(97).ProbablyPrime(8), big.NewInt(99).ProbablyPrime(8))}
Go Reference