Modular inverse

From Rosetta Code
Revision as of 08:33, 30 November 2012 by Grondilu (talk | contribs) (better use a prime as an example for modulo)
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.