Last active
August 29, 2015 14:23
-
-
Save bran921007/36dc9fe071481b362ae0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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