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
10
Task/Modular-inverse/EchoLisp/modular-inverse.echolisp
Normal file
10
Task/Modular-inverse/EchoLisp/modular-inverse.echolisp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(lib 'math) ;; for egcd = extended gcd
|
||||
|
||||
(define (mod-inv x m)
|
||||
(define-values (g inv q) (egcd x m))
|
||||
(unless (= 1 g) (error 'not-coprimes (list x m) ))
|
||||
(if (< inv 0) (+ m inv) inv))
|
||||
|
||||
(mod-inv 42 2017) → 1969
|
||||
(mod-inv 42 666)
|
||||
🔴 error: not-coprimes (42 666)
|
||||
Loading…
Add table
Add a link
Reference in a new issue