Skip to content

Instantly share code, notes, and snippets.

@bouyagas
Forked from sarathsaleem/jsPrime
Created May 23, 2018 02:19
Show Gist options
  • Save bouyagas/02129dbd22d22b35c1130c29d6057e88 to your computer and use it in GitHub Desktop.
Save bouyagas/02129dbd22d22b35c1130c29d6057e88 to your computer and use it in GitHub Desktop.
JavaScript Prime number with recursion
function isPrime(n, hn) {
if (hn === 0 || n === 1) {
return true;
}
hn = hn || parseInt(n / 2);
if (n % hn === 0 && hn !== 1) {
return false;
} else {
return isPrime(n, hn - 1);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment