MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / factorial2

Function factorial2

src/compute-engine/numerics/numeric.ts:216–228  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

214export 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],

Callers 1

arithmetic.tsFile · 0.90

Calls 1

isIntegerMethod · 0.45

Tested by

no test coverage detected