BigInteger.ModPow(BigInteger, BigInteger, BigInteger) Metodo

Definizione

Esegue la divisione modulo su un numero elevato alla potenza di un altro numero.

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

Parametri

value
BigInteger

Numero da elevare alla exponent potenza.

exponent
BigInteger

Esponente da cui generare value .

modulus
BigInteger

Numero in base al quale dividere value la exponent potenza.

Valori restituiti

Resto dopo la divisione value per modulus.

Eccezioni

modulus è zero.

exponent è negativo.

Esempio

Nell'esempio seguente viene fornita una semplice illustrazione della chiamata al ModPow metodo .

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

Commenti

Il ModPow metodo valuta l'espressione seguente:

(baseValue ^ esponente) Modulo mod

Per eseguire l'exponentiation sui BigInteger valori senza divisione modulo, usare il Pow metodo .

Si applica a

Vedi anche