swc/crates/swc_bundler/tests/.cache/deno/382fb214d775279b6be7e1e1f6e3028d3922f449.ts
2021-11-09 20:42:49 +09:00

13 lines
351 B
TypeScript

// Loaded from https://deno.land/x/god_crypto@v0.2.0/src/math.ts
export function power_mod(n: bigint, p: bigint, m: bigint): bigint {
if (p === 1n) return n;
if (p % 2n === 0n) {
const t = power_mod(n, p >> 1n, m);
return (t * t) % m
} else {
const t = power_mod(n, p >> 1n, m);
return (t * t * n) % m
}
}