Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
13
Task/Modular-inverse/Nim/modular-inverse.nim
Normal file
13
Task/Modular-inverse/Nim/modular-inverse.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
proc mulInv(a0, b0): int =
|
||||
var (a, b, x0) = (a0, b0, 0)
|
||||
result = 1
|
||||
if b == 1: return
|
||||
while a > 1:
|
||||
let q = a div b
|
||||
a = a mod b
|
||||
swap a, b
|
||||
result = result - q * x0
|
||||
swap x0, result
|
||||
if result < 0: result += b0
|
||||
|
||||
echo mulInv(42, 2017)
|
||||
Loading…
Add table
Add a link
Reference in a new issue