Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Modular-inverse/AutoHotkey/modular-inverse.ahk
Normal file
19
Task/Modular-inverse/AutoHotkey/modular-inverse.ahk
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
MsgBox, % ModInv(42, 2017)
|
||||
|
||||
ModInv(a, b) {
|
||||
if (b = 1)
|
||||
return 1
|
||||
b0 := b, x0 := 0, x1 :=1
|
||||
while (a > 1) {
|
||||
q := a // b
|
||||
, t := b
|
||||
, b := Mod(a, b)
|
||||
, a := t
|
||||
, t := x0
|
||||
, x0 := x1 - q * x0
|
||||
, x1 := t
|
||||
}
|
||||
if (x1 < 0)
|
||||
x1 += b0
|
||||
return x1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue