Euclid-Mullin sequence: Difference between revisions
→Wren-cli: Aligned code with GMP version and now using library version of Pollard's Rho.
(→Embedded: Re-jigged to find the first 27 numbers in a reasonable time.) |
(→Wren-cli: Aligned code with GMP version and now using library version of Pollard's Rho.) |
||
Line 795:
var two = BigInt.two
var ten = BigInt.ten
var
var
d = BigInt.gcd(z, n)▼
if (n.isProbablePrime(5)) return n
if (n % 2 == zero) return BigInt.two
Line 838 ⟶ 814:
var smallestPrimeFactor = Fn.new { |n|
var s = smallestPrimeFactorWheel.call(n, k100)
if (s) return s
var c = one
if (d == 0) {
if (c == ten) Fiber.abort("Pollard Rho doesn't appear to be working.")
c = c + one
} else {
//
return s ? BigInt.min(s, factor) : factor
}
}
}
Line 867 ⟶ 842:
prod = prod * t
count = count + 1
}
{{out}}
Line 890 ⟶ 865:
</pre>
<br>
===Embedded===
{{libheader|Wren-gmp}}
|