BigInteger.ModPow(BigInteger, BigInteger, BigInteger) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
对提升为另一个数字幂的数字执行取模除法。
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 计算以下表达式:
(baseValue ^ 指数)Mod modulus
若要对 BigInteger 不带模数除法的值执行指数化,请使用 Pow 该方法。