From 4beaa2e2c9e66d02532826de321723d6ff7ce7e5 Mon Sep 17 00:00:00 2001 From: Eduardo Diaz Date: Tue, 4 Aug 2020 10:38:55 -0500 Subject: [PATCH] factorial --- src/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index f16abeb..2175e4c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,7 @@ const factorial = (number) => { - - } + if (number < 0) return; + if (number === 0) return 1; + return number * factorial(number - 1); +}; - module.exports = factorial; \ No newline at end of file +module.exports = factorial;