Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Monday, May 9, 2011

divisors

Q&D aliquot divisor finder

function divisors0(n) {
var divs = [];
var f = 1;
while (f * f <= n) {
if (f == 1 && n != 1) {
divs.push(f);
} else if (f * f == n) {
divs.push(f);
} else if (n % f == 0) {
divs.push(f);
divs.push(n / f);
}
f = f + 1;
}
divs.sort( function(a,b) { return a-b; } );
return divs;
}

Followers

Blog Archive