Skip to content

Instantly share code, notes, and snippets.

@luzperdomo92
Created July 27, 2021 23:47
Show Gist options
  • Save luzperdomo92/8f15174e38f198a1b9812c6a2dff7191 to your computer and use it in GitHub Desktop.
Save luzperdomo92/8f15174e38f198a1b9812c6a2dff7191 to your computer and use it in GitHub Desktop.
rango de numeros primos.
function primos(n) {
for (let i = 2; i < n; i++){
if( n % i === 0){
return;
}
}
return true;
}
function rangePrimos(n1, n2){
let numPrimos = [];
for(let i = n1; i <= n2; i++){
if (primos(i)){
numPrimos.push(i);
}
}
return numPrimos;
}
console.log(rangePrimos(5, 50));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment