challenge-algorithms-v2.0-g.../05-isPrime/index.js

9 lines
237 B
JavaScript
Raw Permalink Normal View History

export function isPrime(value) {
// implementar logica aqui
2022-10-31 16:55:02 +00:00
if (value === 0 || value === 1) return false;
2022-10-31 16:55:02 +00:00
for (let i = 2; i <= Math.sqrt(value); i++) {
if (value % i === 0) return false;
}
return true;
}