Skip to content

Instantly share code, notes, and snippets.

@ramiror
Forked from mcsee/clever.js
Created November 28, 2020 18:45
Show Gist options
  • Save ramiror/64f02937e035c1cbdaff25a0556eb81f to your computer and use it in GitHub Desktop.
Save ramiror/64f02937e035c1cbdaff25a0556eb81f 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