September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,13 +1,12 @@
proc mulInv(a0, b0): int =
proc modInv(a0, b0: int): int =
var (a, b, x0) = (a0, b0, 0)
result = 1
if b == 1: return
while a > 1:
let q = a div b
result = result - (a div b) * x0
a = a mod b
swap a, b
result = result - q * x0
swap x0, result
if result < 0: result += b0
echo mulInv(42, 2017)
echo modInv(42, 2017)