RosettaCodeData/Task/Modular-inverse/00-TASK.txt

19 lines
886 B
Plaintext

From [http://en.wikipedia.org/wiki/Modular_multiplicative_inverse Wikipedia]:
In [[wp:modular arithmetic|modular arithmetic]], &nbsp; the '''modular multiplicative inverse''' of an [[integer]] &nbsp; <big> ''a'' </big> &nbsp; [[wp:modular arithmetic|modulo]] &nbsp; <big> ''m'' </big> &nbsp; is an integer &nbsp; <big> ''x'' </big> &nbsp; such that
::<math>a\,x \equiv 1 \pmod{m}.</math>
Or in other words, such that:
::<math>\exists k \in\Z,\qquad a\, x = 1 + k\,m</math>
It can be shown that such an inverse exists &nbsp; if and only if &nbsp; <big> ''a'' </big> &nbsp; and &nbsp; <big> ''m'' </big> &nbsp; are [[wp:coprime|coprime]], &nbsp; but we will ignore this for this task.
;Task:
Either by implementing the algorithm, by using a dedicated library or by using a built-in function in
your language, &nbsp; compute the modular inverse of &nbsp; 42 modulo 2017.
<br><br>