MCPcopy Index your code
hub / github.com/RustPython/RustPython / inverse

Method inverse

crates/vm/src/builtins/int.rs:416–423  ·  view source on GitHub ↗
(a: BigInt, n: &BigInt)

Source from the content-addressed store, hash-verified

414 if a.is_negative() { a + n } else { a }
415 }
416 fn inverse(a: BigInt, n: &BigInt) -> Option<BigInt> {
417 let ExtendedGcd { gcd, x: c, .. } = a.extended_gcd(n);
418 if gcd.is_one() {
419 Some(normalize(c, n))
420 } else {
421 None
422 }
423 }
424 let a = inverse(a % modulus, modulus).ok_or_else(|| {
425 vm.new_value_error("base is not invertible for the given modulus")
426 })?;

Callers

nothing calls this directly

Calls 2

SomeClass · 0.50
normalizeFunction · 0.50

Tested by

no test coverage detected