Skip to content

Instantly share code, notes, and snippets.

@bran921007
Last active August 29, 2015 14:23
Show Gist options
  • Save bran921007/36dc9fe071481b362ae0 to your computer and use it in GitHub Desktop.
Save bran921007/36dc9fe071481b362ae0 to your computer and use it in GitHub Desktop.
function mmc(r, p, i, m) {
var m = m || [],
i = i || 0,
r2;
r2 = r.map(function(n) {
var n2 = n / p[i];
while(n2 % p[i] !== 0) {
idx++;
}
if(Math.round(n2) === n2) {
r2.push(n2);
m.push(p[i]);
} else {
r2.push(n);
}
});
var isComplete = r2.every(function(n) { return n === 1; });
return isComplete ? m : mmc(r2, p, i, m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment