Skip to content

math/big: ProbablyPrime accepts nonpositive integers as rounds count #9509

@ALTree

Description

@ALTree

Even though only positive integers make sense, ProbablyPrime accepts null and negative integers for the "number of Miller-Rabin rounds" parameter, and happily output true (i.e prime) when given n < 1.

package main

import "math/big"

func main() {
    n := new(big.Int)
    n.SetString("5041", 10) // 71 * 71
    println(n.ProbablyPrime(0)) // true
}

http://play.golang.org/p/vLwhlt3xsC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions