deno.land / x / masx200_leetcode_test@10.6.5 / powx-n / pow_bigint.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export function pow_bigint(x: bigint, n: bigint): bigint { if (n < 0) { throw Error("result not bigint:" + x + "," + n); } const result = n === 1n ? x : x < 0 ? (n % 2n === 0n ? 1n : -1n) * pow_bigint(-x, n) : x === 1n ? 1n : x === 0n ? 0n : n === 0n ? 1n : n % 2n ? x * pow_bigint(x, n - 1n) : pow_bigint(x * x, n / 2n); return result;}
masx200_leetcode_test

Version Info

Tagged at
a year ago