rust-modinverse
Small library for finding the modular multiplicative inverses. Also has an implementation of the extended Euclidean algorithm built in.
modinverse
Calculates the modular multiplicative inverse x of an integer a such that ax ≡ 1 (mod m).
Such an integer may not exist. If so, this function will return None
.
Otherwise, the inverse will be returned wrapped up in a Some
.
use modinverse;
let does_exist = modinverse;
let does_not_exist = modinverse;
match does_exist
match does_not_exist
egcd
Finds the greatest common denominator of two integers a and b, and two integers x and y such that ax + by is the greatest common denominator of a and b (Bézout coefficients).
This function is an implementation of the extended Euclidean algorithm.
use egcd;
let a = 26;
let b = 3;
let = egcd;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;