Category talk:Wren-math: Difference between revisions
→Source code: Added Int.distinctPrimeFactors method.
(→Source code: Added Int.totient mehod.) |
(→Source code: Added Int.distinctPrimeFactors method.) |
||
Line 705:
}
if (n > 1) factors.add(n)
return factors
}
// Returns a list of the distinct prime factors of 'n' in order.
static distinctPrimeFactors(n) {
var factors = primeFactors(n)
if (factors.count < 2) return factors
for (i in factors.count-1..1) {
if (factors[i] == factors[i-1]) factors.removeAt(i)
}
return factors
}
|