Created
July 27, 2021 23:47
-
-
Save luzperdomo92/8f15174e38f198a1b9812c6a2dff7191 to your computer and use it in GitHub Desktop.
rango de numeros primos.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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