Created
March 11, 2012 04:15
-
-
Save thomas4g/2014989 to your computer and use it in GitHub Desktop.
Greatest Prime - Recursion
This file contains 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 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