forked from M3-Academy/challenge-algorithms-v2.0
Merge pull request 'feat(isPrime): adiciona resolucao questao05-isprime' (#5) from feature/isPrime into development
Reviewed-on: #5
This commit is contained in:
commit
0d0ca5f86d
@ -1,4 +1,11 @@
|
|||||||
export function isPrime(value) {
|
export function isPrime(value) {
|
||||||
// implementar logica aqui
|
// 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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user