ModPowL function

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Math

Package: Microsoft.Quantum.QSharp.Foundation

Performs modular division on a number raised to the power of another number.

function ModPowL (value : BigInt, exponent : BigInt, modulus : BigInt) : BigInt

Input

value : BigInt

The value to be raised to the given exponent.

exponent : BigInt

The exponent to which value is to be raised.

modulus : BigInt

The modulus with respect to which value ^ exponent is to be computed.

Output : BigInt

The result of (value ^ exponent) % modulus.

Example

The following snippet computs $11^31415 \bmod 13$:

let result = ModPowL(11, 31415, 13);  // 6

Remarks

The implementation of this function takes the modulus at each step, making it much more efficient than (value ^ exponent) % modulus for large values of value and exponent.