* Compute factorial as a BigDecimal string.
(n: number)
| 45 | * Compute factorial as a BigDecimal string. |
| 46 | */ |
| 47 | function factorial(n: number): string { |
| 48 | let result = 1n; |
| 49 | for (let i = 2; i <= n; i++) result *= BigInt(i); |
| 50 | return result.toString(); |
| 51 | } |
| 52 | |
| 53 | function withPrecision<T>(prec: number, fn: () => T): T { |
| 54 | const savedBD = BigDecimal.precision; |
no test coverage detected