語言

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

分數 value 的數字被提升為 exponent 冪次。

傳回

其餘部分除valuemodulus後。

例外狀況

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
open System.Numerics;

let number = 10I;
let exponent = 3;
let modulus = 30I;
printfn $"({number}^{exponent}) Mod {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 方法評估以下表達式:

(基值 ^ 指數)模模數

若要對 BigInteger 無模除的數值進行指數運算,請使用該 Pow 方法。

適用於

另請參閱