which can be further broken down into quantum gates appropriate for a specific physical device. Furthermore, in Shor's algorithm it is possible to know the base and the modulus of exponentiation at every call, which enables various circuit optimizations. Software implementations Because modular exponentiation is an important operation in computer science, and there are efficient algorithms (see above) that are much faster than simply exponentiating and then taking the remainder, many programming languages and arbitrary-precision integer libraries have a dedicated function to perform modular exponentiation: Python's built-in pow() (exponentiation) function takes an optional third argument, the modulus .NET Framework's BigInteger class has a ModPow() method to perform modular exponentiation Java's java.math.BigInteger class has a method to perform modular exponentiation MATLAB's powermod function from Symbolic Math Toolbox Wolfram Language has the PowerMod function Perl's Math::BigInt module has a bmodpow() method to perform modular exponentiation Raku has a built-in routine expmod. Go's big.Int type contains an Exp() (exponentiation) method whose third parameter, if non-nil, is the modulus PHP's BC Math library has a bcpowmod() function to perform modular exponentiation The GNU Multiple Precision Arithmetic Library (GMP) library contains a mpz_powm() function to perform modular exponentiation Custom Function @PowerMod() for FileMaker Pro (with 1024-bit RSA encryption example) Ruby's openssl package has the OpenSSL::BN#mod_exp method to perform modular exponentiation. The HP Prime Calculator has the CAS.powmod() function to perform modular exponentiation. For a^b mod c, a can be no larger than 1 EE 12. This is the maximum precision of most HP calculators including the Prime. See also Montgomery reduction, for calculating the remainder when the modulus is very large. Kochanski multiplication, serializable method for calculating the remainder when the modulus is very large Barrett reduction, algorithm for calculating the remainder when the modulus is very large. References External links Paul Garrett, Fast Modular Exponentiation Java Applet Cryptographic algorithms Number theoretic algorithms Modular arithmetic Articles with example pseudocode