Skip to content

Instantly share code, notes, and snippets.

@Dykam
Created April 7, 2011 11:03
Show Gist options
  • Save Dykam/907570 to your computer and use it in GitHub Desktop.
Save Dykam/907570 to your computer and use it in GitHub Desktop.
divide = function(n) {
var sqrtN = Math.floor(Math.sqrt(n));
var i = 1;
while(i++ < sqrtN)
if(n % i == 0)
return [i].concat(divide(n / i));
return [n];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment