feat(isPrime): adiciona resolucao questao05-isprime

This commit is contained in:
carloswinter 2022-10-28 16:02:38 -03:00
parent 8518be3bbb
commit 117127ae38

View File

@ -1,4 +1,11 @@
export function isPrime(value) {
// implementar logica aqui
if (isNaN(value) || !isFinite(value) || value % 1 || value < 2)
return false;
if (value % 2 == 0)
return (value == 2);
for (let i = 3; i <= Math.sqrt(value); i += 2) {
if (value % i == 0) return false;
}
return true;
}