Category talk:Wren-long: Difference between revisions
Content added Content deleted
(→Source code: Improved algorithm for ULong.divisors2 and added divisorSum and divisorCount methods.) |
m (No need for ULong qualifier.) |
||
Line 1,018: | Line 1,018: | ||
static divisors2(n) { |
static divisors2(n) { |
||
if (n is Num) n = ULong.new(n) |
if (n is Num) n = ULong.new(n) |
||
var pf = |
var pf = primeFactors(n) |
||
if (pf.count == 0) return (n == 1) ? [one] : pf |
if (pf.count == 0) return (n == 1) ? [one] : pf |
||
var arr = [] |
var arr = [] |
||
Line 1,062: | Line 1,062: | ||
// Returns the sum of all the divisors of 'n' including 1 and 'n' itself. |
// Returns the sum of all the divisors of 'n' including 1 and 'n' itself. |
||
static divisorSum(n) { |
static divisorSum(n) { |
||
if (n < 1) return |
if (n < 1) return zero |
||
if (n is Num) n = ULong.new(n) |
if (n is Num) n = ULong.new(n) |
||
var total = one |
var total = one |