Category talk:Wren-i64: Difference between revisions

U64.isPrime method now uses a 'witness' list appropriate to the size of number.
(Added U64.modInv method.)
(U64.isPrime method now uses a 'witness' list appropriate to the size of number.)
Line 604:
if (isbp != null) return isbp
if (x > largest/two) Fiber.abort("Cannot test %(x) for primality.")
var a
return millerRabinTest_(x, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])
if (x < 2047) {
a = [2]
} else if (x < 1373653) {
a = [2, 3]
} else if (x < 9080191) {
a = [31, 73]
} else if (x < 25326001) {
a = [2, 3, 5]
} else if (x < 3215031751) {
a = [2, 3, 5, 7]
} else if (x < 4759123141) {
a = [2, 7, 61]
} else if (x < 1122004669633) {
a = [2, 13, 23, 1662803]
} else if (x < 2152302898747) {
a = [2, 3, 5, 7, 11]
} else if (x < 3474749660383) {
a = [2, 3, 5, 7, 11, 13]
} else if (x < 341550071728321) {
a = [2, 3, 5, 7, 11, 13, 17]
} else if (x < from("3825123056546413051")) {
a = [2, 3, 5, 7, 11, 13, 17, 19, 23]
} else {
return millerRabinTest_(x, a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])
}
return millerRabinTest_(x, a)
}
 
// Returns the next prime number greater than 'x'.
static nextPrime(x) {
9,476

edits