Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,20 @@
extension BinaryInteger {
@inlinable
public func modInv(_ mod: Self) -> Self {
var (m, n) = (mod, self)
var (x, y) = (Self(0), Self(1))
while n != 0 {
(x, y) = (y, x - (m / n) * y)
(m, n) = (n, m % n)
}
while x < 0 {
x += mod
}
return x
}
}
print(42.modInv(2017))