Category talk:Wren-big: Difference between revisions

→‎Source code: Added BigInt.prevPrime method.
(→‎Source code: Added BigRat.roundUp method.)
(→‎Source code: Added BigInt.prevPrime method.)
Line 967:
}
 
// Returns the previous probable prime number less than 'this' or null if there isn't one.
// Convenience version of the above method which uses 5 iterations.
prevPrime(iterations) {
if (this < BigInt.three) return null
if (this == BigInt.three) return BigInt.two
var n = isEven ? this - 1 : this - 2
while (true) {
if (n.isProbablePrime(iterations)) return n
n = n - 2
}
}
 
// Convenience versionversions of the above methodmethods which usesuse 5 iterations.
nextPrime { nextPrime(5) }
prevPrime { prevPrime(5) }
 
// Negates a BigInt.
9,482

edits