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

Function carmichaelLambda

src/compute-engine/library/number-theory.ts:1288–1303  ·  view source on GitHub ↗

Carmichael's reduced totient λ(n) from the prime factorization (`n ≥ 1`).

(n: bigint)

Source from the content-addressed store, hash-verified

1286 const seen = new Set<bigint>();
1287 let k = toBigint(n);
1288 // Happy numbers are positive integers; a negative `k` would also make
1289 // `sumSquareDigits` throw on the "-" sign.
1290 if (k === null || k < 1n) return ce.False;
1291 while (!seen.has(k)) {
1292 if (k === 1n) return ce.True;
1293 seen.add(k);
1294 k = sumSquareDigits(k);
1295 }
1296 return ce.False;
1297 },
1298 },
1299
1300 IsAbundant: {
1301 description: 'True if n is an abundant number (sum of divisors > 2n).',
1302 signature: '(integer) -> boolean',
1303 evaluate: ([n], { engine: ce }) => {
1304 const k = toBigint(n);
1305 if (k === null || k < 1n) return ce.False;
1306 let sum = 1n;

Callers 1

number-theory.tsFile · 0.85

Calls 2

bigPrimeFactorsFunction · 0.90
lcmFunction · 0.90

Tested by

no test coverage detected