Modular inverse: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{draft task}} From [http://en.wikipedia.org/wiki/Modular_multiplicative_inverse Wikipedia]: :In wp:modular arithmetic, the '''modular multiplicative inverse''' of an [[...")
 
m (better use a prime as an example for modulo)
Line 11: Line 11:
It can be shown that such an inverse exists if and only if a and m are [[wp:coprime|coprime]], but we will ignore this for this task.
It can be shown that such an inverse exists if and only if a and m are [[wp:coprime|coprime]], but we will ignore this for this task.


Either by implementing the algorithm, or by using a builtin function in your language, compute the modular inverse of 42 modulo 2013.
Either by implementing the algorithm, or by using a builtin function in your language, compute the modular inverse of 42 modulo 2017.

Revision as of 08:33, 30 November 2012

Modular inverse is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

From Wikipedia:

In modular arithmetic, the modular multiplicative inverse of an integer a modulo m is an integer x such that

Or in other words, such that

It can be shown that such an inverse exists if and only if a and m are coprime, but we will ignore this for this task.

Either by implementing the algorithm, or by using a builtin function in your language, compute the modular inverse of 42 modulo 2017.