(n)
| 9 | */ |
| 10 | |
| 11 | const factorial = (n) => { |
| 12 | if (!Number.isInteger(n) || n < 0) { |
| 13 | throw new RangeError('Input should be a non-negative whole number') |
| 14 | } |
| 15 | |
| 16 | if (n === 0) { |
| 17 | return 1 |
| 18 | } |
| 19 | |
| 20 | return n * factorial(n - 1) |
| 21 | } |
| 22 | |
| 23 | export { factorial } |
no outgoing calls
no test coverage detected