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

定義

一個數目自乘至另一個數目的乘冪後,執行模數除法。

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 的數字。

exponent
BigInteger

value 的乘冪指數。

modulus
BigInteger

要除以具有乘冪數 valueexponent 的數字。

傳回

value指數 除以 modulus 後的餘數。

例外狀況

modulus 為零。

exponent 為負。

範例

下列範例提供呼叫 ModPow 方法的簡單圖例。

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 會評估下列運算式:

(baseValue ^ 指數) 模數

若要對 BigInteger 沒有模數除法的值執行指數,請使用 Pow 方法。

適用於

另請參閱