C# BigInteger ModPow
Description
BigInteger ModPow
Performs modulus division on a number
raised to the power of another number.
Syntax
BigInteger.ModPow
has the following syntax.
public static BigInteger ModPow(
BigInteger value,// ww w . j av a 2 s .c om
BigInteger exponent,
BigInteger modulus
)
Parameters
BigInteger.ModPow
has the following parameters.
value
- The number to raise to the exponent power.exponent
- The exponent to raise value by.modulus
- The number by which to divide value raised to the exponent power.
Returns
BigInteger.ModPow
method returns The remainder after dividing valueexponent by modulus.
Example
using System;/* w w w .java2 s . c o m*/
using System.Numerics;
public class Class1
{
public static void Main()
{
BigInteger number = 10;
int exponent = 3;
BigInteger modulus = 30;
Console.WriteLine("({0}^{1}) Mod {2} = {3}",
number, exponent, modulus,
BigInteger.ModPow(number, exponent, modulus));
}
}
The code above generates the following result.