Modular inverse

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

Rosetta Code
I just added a second version that requires no malloc-free.

I have now added #Oberon2 --

https://rosettacode.org/wiki/Modular_inverse#Oberon-2

#RosettaCode #Oberon

(UPDATE: Now with bugfix and regression test.)

Modular inverse

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

Rosetta Code

Now #Fortran --
https://rosettacode.org/wiki/Modular_inverse#Fortran

Fortran provides MODULO, which is the remainder from floor division. From this one can get the floor quotient.

The Oberon-2 spec says that, for a positive divisor, DIV and MOD should give a non-negative remainder. But obc doesn’t follow that specification. (I know it’s not held to the spec, however. That’s how come I had the foresight to test it.)

Modular inverse

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

Rosetta Code

Surely a language that is a lot of fun to use---here is the #Mercury ---

https://rosettacode.org/wiki/Modular_inverse#Mercury

Modular inverse

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

Rosetta Code
Modular inverse

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

Rosetta Code
Modular inverse

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

Rosetta Code

And my first ever program in #OwlLisp --

https://rosettacode.org/wiki/Modular_inverse#Owl_Lisp

Using a PURELY functional Scheme requires at least a small change in thinking. (Also it seems not to have unary minus sign.)

Modular inverse

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

Rosetta Code