BigInteger.ModPow(BigInteger, BigInteger, BigInteger) 方法

定义

对以某个数为底、以另一个数为指数的幂执行模数除法。Performs modulus division on a number raised to the power of another number.

public:
 static System::Numerics::BigInteger ModPow(System::Numerics::BigInteger value, System::Numerics::BigInteger exponent, System::Numerics::BigInteger modulus);
public static System.Numerics.BigInteger ModPow (System.Numerics.BigInteger value, System.Numerics.BigInteger exponent, System.Numerics.BigInteger modulus);
static member ModPow : System.Numerics.BigInteger * System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Function ModPow (value As BigInteger, exponent As BigInteger, modulus As BigInteger) As BigInteger

参数

value
BigInteger

要计算 exponent 次幂的数字。The number to raise to the exponent power.

exponent
BigInteger

value 进行幂运算的指数。The exponent to raise value by.

modulus
BigInteger

valueexponent 次幂要除以的数值。The number by which to divide value raised to the exponent power.

返回

valueexponent 除以 modulus 后的余数。The remainder after dividing valueexponent by modulus.

例外

modulus 为零。modulus is zero.

exponent 为负数。exponent is negative.

示例

下面的示例提供了调用 ModPow 方法的简单阐释。The following example provides a simple illustration of calling the ModPow method.

using System;
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 example displays the following output:
//      (10^3) Mod 30 = 10
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim number As BigInteger = 10
      Dim exponent As Integer = 3
      Dim modulus As BigInteger = 30
      Console.WriteLine("({0}^{1}) Mod {2} = {3}", _
                        number, exponent, modulus, _
                        BigInteger.ModPow(number, exponent, modulus))
   End Sub   
End Module
' The example displays the following output:
'       (10^3) Mod 30 = 10      

注解

ModPow 方法计算以下表达式:The ModPow method evaluates the following expression:

(接受 basevalue ^ 指数)Mod 取模(baseValue ^ exponent) Mod modulus

若要对没有模数除法 BigInteger 值执行幂运算,请使用 Pow 方法。To perform exponentiation on BigInteger values without modulus division, use the Pow method.

适用于

另请参阅