From f98db45a0358f26aed5e5c19b6fdd3d9371feafa Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Sat, 29 Oct 2022 18:50:55 -0300 Subject: [PATCH] feat(isPrime): Utilizando loop while, Math.sqrt para retornar a raiz dos valores passados, funcional em todos os testes. --- 05-isPrime/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..805d2b6 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,6 @@ export function isPrime(value) { // implementar logica aqui - + var start = 2; + while (start <= Math.sqrt(value)) if (value % start++ < 1) return false; + return value > 1; } \ No newline at end of file