RosettaCodeData/Task/Modular-inverse/00DESCRIPTION

17 lines
875 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
From [http://en.wikipedia.org/wiki/Modular_multiplicative_inverse Wikipedia]:
2016-12-05 22:15:40 +01:00
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
2013-04-10 21:29:02 -07:00
2014-04-02 16:56:35 +00:00
::<math>a\,x \equiv 1 \pmod{m}.</math>
2013-04-10 21:29:02 -07:00
Or in other words, such that:
2016-12-05 22:15:40 +01:00
::<math>\exists k \in\Z,\qquad a\, x = 1 + k\,m</math>
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
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.