Category talk:Wren-i64: Difference between revisions
Content added Content deleted
m (→Source code (Wren): Tweak.) |
(→Source code (Wren): Removed the previous limitation on the U64.isPrime method.) |
||
Line 623: | Line 623: | ||
// Returns true if 'x' is prime, false otherwise. |
// Returns true if 'x' is prime, false otherwise. |
||
// Fails due to overflow on numbers > 9223372036854775807 unless divisible by 2,3 or 5. |
|||
static isPrime(x) { |
static isPrime(x) { |
||
if (!(x is U64)) x = from(x) |
if (!(x is U64)) x = from(x) |
||
var isbp = isBasicPrime_(x) |
var isbp = isBasicPrime_(x) |
||
if (isbp != null) return isbp |
if (isbp != null) return isbp |
||
if (x > largest/two) Fiber.abort("Cannot test %(x) for primality.") |
|||
var a |
var a |
||
if (x < 2047) { |
if (x < 2047) { |