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 61c0db0656 - Show all commits

View File

@ -16,6 +16,26 @@
*/
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
}