Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Modular exponentiation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 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 (programming language)|Python]]'s built-in <code>pow()</code> (exponentiation) function [https://docs.python.org/library/functions.html#pow] takes an optional third argument, the modulus * [[.NET Framework]]'s <code>BigInteger</code> class has a <code>[http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.modpow%28v=vs.100%29.aspx#pow ModPow()]</code> method to perform modular exponentiation * [[Java (programming language)|Java]]'s <code>java.math.BigInteger</code> class has a {{Javadoc:SE|name=modPow()|java/math|BigInteger|modPow(java.math.BigInteger,java.math.BigInteger)}} method to perform modular exponentiation * [[MATLAB]]'s <code>powermod</code> function from Symbolic Math Toolbox *Wolfram Language has the [https://reference.wolfram.com/language/ref/PowerMod.html PowerMod] function * [[Perl]]'s <code>Math::BigInt</code> module has a <code>bmodpow()</code> method [http://perldoc.perl.org/Math/BigInt.html#bmodpow%28%29] to perform modular exponentiation * [[Raku (programming language)|Raku]] has a built-in routine <code>expmod</code>. * [[Go (programming language)|Go]]'s <code>big.Int</code> type contains an <code>Exp()</code> (exponentiation) method [http://golang.org/pkg/big/#Int.Exp] whose third parameter, if non-nil, is the modulus * [[PHP]]'s BC Math library has a <code>bcpowmod()</code> function [http://www.php.net/manual/en/function.bcpowmod.php] to perform modular exponentiation * The [[GNU Multiple Precision Arithmetic Library]] (GMP) library contains a <code>mpz_powm()</code> function [http://gmplib.org/manual/Integer-Exponentiation.html] to perform modular exponentiation * Custom Function <code>[http://www.briandunning.com/cf/1482 @PowerMod()]</code> for [[FileMaker]] Pro (with 1024-bit [[RSA (algorithm)|RSA]] encryption example) * [[Ruby (programming language)|Ruby]]'s <code>openssl</code> package has the <code>OpenSSL::BN#mod_exp</code> method [https://docs.ruby-lang.org/en/master/OpenSSL/BN.html#method-i-mod_exp] to perform modular exponentiation.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)