Skip to content

Instantly share code, notes, and snippets.

@thomas4g
Created March 11, 2012 04:15
Show Gist options
  • Save thomas4g/2014989 to your computer and use it in GitHub Desktop.
Save thomas4g/2014989 to your computer and use it in GitHub Desktop.
Greatest Prime - Recursion
function factor(num, index) {
if(!index) index = 2;
var lim = Math.ceil(num/2)+1, result=num;
if(index < lim) {
if(num%index === 0) {
return factor2(num/index);
}
result = factor(num, ++index;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment