Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active November 23, 2022 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mcsee/df27505a28b5f65faaa273b0bfe1f322 to your computer and use it in GitHub Desktop.
Save mcsee/df27505a28b5f65faaa273b0bfe1f322 to your computer and use it in GitHub Desktop.
function primeFactors(n) {
var f = [], i = 0, d = 2;
for (i = 0; n >= 2; ) {
if(n % d == 0) {
f[i++]=(d);
n /= d;
}
else {
d++;
}
}
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment