Jump to content

Category talk:Wren-gmp: Difference between revisions

m
→‎Source code (Wren): Removed some surplus whitespace.
m (→‎Source code (Wren): Removed a duplicated program comment.)
m (→‎Source code (Wren): Removed some surplus whitespace.)
Line 458:
if (m < 2) return Mpz.zero
if (m is Num) m = Mpz.from(m)
if (m.probPrime(15) > 0) return m.copy()
if (m.isSquare) return m.copy().sqrt
for (p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) {
Line 475:
var factors = []
var k = Mpz.from(37)
var i = 0
while (k * k <= n) {
if (n.isDivisible(k)) {
Line 489:
}
 
// Private worker method (recursive) to obtain the prime factors of a number (Mpz).
static primeFactors_(m, trialDivs) {
if (m.probPrime(15) > 0) return [m.copy()]
Line 511:
break
}
if (n >= threshold) {
var d = pollardRho_(n, seed, c)
if (d != 0) {
Line 528:
checkPrime = false
}
 
} else if (c < 101) {
c = c + 1
Line 536 ⟶ 535:
factors.addAll(primeFactorsWheel_(n))
break
}
} else {
factors.addAll(primeFactorsWheel_(n))
Line 547 ⟶ 546:
 
// Returns a list of the primes factors (Mpz) of 'm' (an Mpz object or an integral Num)
// using the wheel based factorization and/or Pollard's Rho algorithm as appropriate.
static primeFactors(m) {
if (m < 2) return []
9,492

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.