Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Js

Idiom #66 Big integer exponentiation

Calculate the result z of x power n, where x is a big integer and n is a positive integer.

let z = x**n

x and n should be of type BigInt, which is only supported in NodeJS, Firefox, and Chrome
using System.Numerics;
var z = BigInteger.Pow(x, n);

New implementation...