```{index} single: bmodinv; Math::GMP function ``` ```{index} single: Math::GMP::bmodinv; Perl function ``` # bmodinv Return the modular inverse of `$x` mod `$y`. ## Synopsis ```perl my $x = Math::GMP->new(5); my $inv = $x->bmodinv(7); # 3, because 5 * 3 == 1 (mod 7) ``` When `$x` has no inverse modulo `$y` (i.e. `gcd($x, $y) != 1`), returns `0`. Behaviour is undefined when `$y` is `0`. ## Edge cases - `bmodinv` returning `0` is ambiguous: `0` is never a valid inverse, so treat it as "no inverse exists".