diff --git a/src/algorithms/math/factorial/factorial.js b/src/algorithms/math/factorial/factorial.js index 6c717d05..1e8eb0a6 100644 --- a/src/algorithms/math/factorial/factorial.js +++ b/src/algorithms/math/factorial/factorial.js @@ -11,3 +11,16 @@ export default function factorial(number) { return result; } +/** + * @param {number} number + * @return {number} + * Recursive solution + */ +export default function factorial(number){ + if (number>=1){ + return number*factorial(number-1); + } + else{ + return 1 + } +}