summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luacas/tex/test/rings/modulararithmetic.lua
blob: 1bd315595af42ecfe39c6ea0ddff540116665eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local a = IntegerModN(Integer(5), Integer(3))
local b = IntegerModN(Integer(1), Integer(3))
local c = IntegerModN(Integer(-12), Integer(3))
local f = IntegerModN(Integer(100), Integer(62501))
local d = IntegerModN(Integer(16), Integer(36))
local e = IntegerModN(Integer(27), Integer(36))

starttest("modular arithmetic")
testeq(a, "2")
testeq(b, "1")
testeq(c, "0")
testeq(a + b, "0")
testeq(a - b, "1")
testeq(a * b, "2")
testeq(a:inv(), "2")
testeq(b:inv(), "1")
testeq(f:inv(), "61876")
testeq(d * e, "0")
testeq(a * d, "2")
endtest()