Category talk:Wren-big: Difference between revisions

→‎Source code: Added BigInt.nextPrime method.
(→‎Source code: Harmonization of constants between numeric modules.)
(→‎Source code: Added BigInt.nextPrime method.)
Line 956:
isPrime { isPrime(false) }
isProbablePrime { isProbablePrime(5) }
 
// Returns the next probable prime number greater than 'this'.
nextPrime(iterations) {
var n = isEven ? this + 1 : this + 2
while (true) {
if (n.isProbablePrime(iterations)) return n
n = n + 2
}
}
 
// Convenience version of the above method which uses 5 iterations.
nextPrime { nextPrime(5) }
 
// Negates a BigInt.
9,485

edits