diff --git a/05-é-primo/index.html b/05-é-primo/index.html index e7ad135..25d6b17 100644 --- a/05-é-primo/index.html +++ b/05-é-primo/index.html @@ -16,28 +16,12 @@ */ function isPrime(number) { // implementar logica aqui - if (number === 2 || number === 3) return true - if (number % 2 === 0 || number < 2) return false - - var s = 0, - d = number - 1 - while ((d & 1) == 0) { - d >>= 1 - ++s - } - - let base = 2 - var x = Math.pow(base, d) % number - - if (x == 1 || x == number - 1) return true - - for (var i = 1; i <= s; i++) { - x = (x * x) % number - - if (x === number - 1) return true - } - return false - } + for (let i = 2; i < number; i++) + if (number % i === 0) { + return false; + } + return number > 1; + } // Resultados esperados console.log(isPrime(2), true) // true