Logo

Programming-Idioms

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

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.

import std.bigint;
BigInt z = x ^^ n;
using System.Numerics;
var z = BigInteger.Pow(x, n);
import "dart:math";
var z = pow(x, n);
z = :math.pow(x, n)
import "math/big"
nb := big.NewInt(int64(n))
var z big.Int
z.Exp(x, nb, nil)
z = x ^ n
let z = x**n
import java.math.BigInteger;
BigInteger z = x.pow(n);
use bigint;
my ($x, $y) = (3 ** 200, 25);
my $z = $x ** $y;
z = x**n
z = x ** n
extern crate num;
let z = num::pow(x, n);
z := x raisedTo: n.
z := x ** n.

New implementation...