AngouriMath

Navigation

← Back to list of members

ModularInverse​(AngouriMath.​Entity.​Number.​Integer,​AngouriMath.​Entity.​Number.​Integer)

 Method (no overloads)

Summary

The multiplicative inverse of a modulo n:
the one representative in [1, n - 1] of the class of x with
a x = 1 (mod n), or null where there is none, which is
exactly when a and n share a factor. A class, never the number
1/a. https://github.com/asc-community/AngouriMath/issues/1409

Example

Console.WriteLine(MathS.NumberTheory.ModularInverse(3, 10));
Console.WriteLine(MathS.NumberTheory.ModularInverse(6, 15) is null);

Prints
7
True

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online