(require-extension test modular-arithmetic) (test-group "Modular Arithmetic" (test "Extended GCD" '(3 -2) (receive (xgcd 15 21))) (test "Addition" 3 (with-modulus 7 (+ 1 2 3 4))) (test "Subtraction" 2 (with-modulus 5 (- 4 7))) (test "Multiplication" 50 (with-modulus 66 (* 4 8 16))) (test "Division" 1 (with-modulus #xE95E4A5F737059DC60DFC7AD95B3D8139515620F ((lambda (x) (/ x x)) 8977423876425786243783246))) (test "Exponentiation" 8 (with-modulus 13 (expt 5 3))) ) (test-exit)