From 49152ef2fbb4410599903ef8fd009c59edfdd45c Mon Sep 17 00:00:00 2001 From: kelly <85955516+kellyjohanasalb@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:03:30 -0500 Subject: [PATCH 1/3] =?UTF-8?q?soluci=C3=B3n=20de=20factorial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/factorial.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/factorial.js b/src/factorial.js index 4f3ae70..b323006 100644 --- a/src/factorial.js +++ b/src/factorial.js @@ -1,5 +1,9 @@ -const factorial = (number) => { - // your code here +function factorial(num) { + let resultado = 1; + for (let i = 1; i <= num; i++) { + resultado *= i; + } + return resultado; } -module.exports = factorial; \ No newline at end of file +module.exports = factorial; From 9fcc999dba569dc692bc7be988eb11d4b213f7bf Mon Sep 17 00:00:00 2001 From: kelly <85955516+kellyjohanasalb@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:06:33 -0500 Subject: [PATCH 2/3] =?UTF-8?q?mi=20soluci=C3=B3n=20al=20primial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aquí pongo mi código en javascript --- src/primalidad.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/primalidad.js b/src/primalidad.js index 8bdb849..220a0d3 100644 --- a/src/primalidad.js +++ b/src/primalidad.js @@ -1,5 +1,11 @@ -const trialDivision = (number) => { - // your code here +function esPrimo(num) { + if (num < 2) { + return false; + } + for (let i = 2; i <= Math.floor(Math.sqrt(num)); i++) { + if (num % i === 0) { + return false; + } + } + return true; } - -module.exports = trialDivision; \ No newline at end of file From 06d6d7d809d6e0d75a9c4c61b0d153c40fa00365 Mon Sep 17 00:00:00 2001 From: kelly <85955516+kellyjohanasalb@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:09:11 -0500 Subject: [PATCH 3/3] =?UTF-8?q?si=20los=20primeros=2010=20n=C3=BAmeros=20d?= =?UTF-8?q?e=20fibonacci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aquí anexo los primero 10 números de fibonacci --- src/fibonacci.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fibonacci.js b/src/fibonacci.js index ea3270f..4f71d34 100644 --- a/src/fibonacci.js +++ b/src/fibonacci.js @@ -1,5 +1,5 @@ const fibonacci = (n) => { - // your code here + 1,1,2,3 } -module.exports = fibonacci; \ No newline at end of file +module.exports = fibonacci;