BigInteger.ModPow(BigInteger, BigInteger, BigInteger) Metoda

Definicja

Wykonuje dzielenie modulo na liczbie podniesionej do potęgi innej liczby.

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

Parametry

value
BigInteger

Liczba, która ma podnieść moc exponent .

exponent
BigInteger

Wykładnik, o który należy podnieść value .

modulus
BigInteger

Liczba, za pomocą której należy podzielić valueexponent moc.

Zwraca

Pozostała część po podzieleniu valuewykładnika przez modulus.

Wyjątki

modulus jest zero.

exponent jest ujemna.

Przykłady

Poniższy przykład zawiera prostą ilustrację wywoływania ModPow metody .

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

Uwagi

Metoda ModPow oblicza następujące wyrażenie:

(wykładnik baseValue ^) Modulo mod

Aby wykonać wykładnik na BigInteger wartościach bez dzielenia modulo, użyj Pow metody .

Dotyczy

Zobacz też