Entrega do Desafio #1

Merged
anacarolinaduartecavalcante merged 10 commits from feature/09-caractere-mais-repetido into master 2022-10-24 19:09:34 +00:00
Showing only changes of commit 43639c8215 - Show all commits

View File

@ -16,27 +16,11 @@
*/ */
function isPrime(number) { function isPrime(number) {
// implementar logica aqui // implementar logica aqui
if (number === 2 || number === 3) return true for (let i = 2; i < number; i++)
if (number % 2 === 0 || number < 2) return false if (number % i === 0) {
return false;
var s = 0, }
d = number - 1 return 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
} }
// Resultados esperados // Resultados esperados