(n: number)
| 214 | export function canonicalInteger( |
| 215 | n: number, |
| 216 | exponent: number |
| 217 | ): readonly [factor: number, root: number] { |
| 218 | if (n >= Number.MAX_SAFE_INTEGER) return [1, n]; |
| 219 | if (n === 0) return [0, 0]; |
| 220 | if (n === 1) return [1, 1]; |
| 221 | // @todo: handle negative n |
| 222 | console.assert(Number.isInteger(n) && n > 0 && n < Number.MAX_SAFE_INTEGER); |
| 223 | if (exponent === 2) { |
| 224 | const result = ( |
| 225 | [ |
| 226 | [0, 0], |
| 227 | [1, 1], |
| 228 | [1, 2], |
| 229 | [1, 3], |
| 230 | [2, 1], |
| 231 | [1, 5], |