(num: number)
| 8 | * @example factorial(3) = 6 |
| 9 | */ |
| 10 | export const factorial = (num: number): number => { |
| 11 | if (num < 0 || !Number.isInteger(num)) { |
| 12 | throw new Error('only natural numbers are supported') |
| 13 | } |
| 14 | |
| 15 | return num === 0 ? 1 : num * factorial(num - 1) |
| 16 | } |
no outgoing calls
no test coverage detected