Files
30-seconds-of-code/test/factorial/factorial.js
2018-01-09 06:09:49 -05:00

6 lines
138 B
JavaScript

module.exports = n =>
n < 0
? (() => {
throw new TypeError('Negative numbers are not allowed!');
})()
: n <= 1 ? 1 : n * factorial(n - 1);