Skip to content

Instantly share code, notes, and snippets.

@ShaakhDev
Last active February 25, 2023 09:54
Show Gist options
  • Save ShaakhDev/e1c399bcd08c7130d588ed6d2d987a34 to your computer and use it in GitHub Desktop.
Save ShaakhDev/e1c399bcd08c7130d588ed6d2d987a34 to your computer and use it in GitHub Desktop.
Logging all prime factors of given number
function primeFactors(n){
while(n % 2 == 0){
console.log(2);
n = n / 2
};
for(var i = 3; i * i <= n; i = i + 2){
while(n % 2 == 0){
console.log(n);
n = n / i;
}
}
if(n > 2) console.log(n);
}
@ShaakhDev
Copy link
Author

sonni tub ko'paytuvchilarga ajratish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment