Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

build open-axiom

54510 views
)clear all
x1:=4
m1:=5
x2:=2
m2:=3
result:=chineseRemainder(x1,m1,x2,m2)
expected:=14
if (result-expected ~=0) then print "DALY BUG"

)clear completely 

inverse:(INT,INT)->INT

inverse(a,b) ==
  borg:INT:=b
  c1:INT := 1
  d1:INT := 0
  while b ~= 0 repeat
    q := a quo b
    r := a-q*b
    print [a, "=", q, "*(", b, ")+", r]
    (a,b):=(b,r)
    (c1,d1):=(d1,c1-q*d1)
  not one? a => error("moduli are not relatively prime")
  positiveRemainder(c1,borg)

if not one?((inverse(26,15)*26)::IntegerMod(15)) then print "DALY BUG"
if not one?((inverse(15,26)*15)::IntegerMod(26)) then print "DALY BUG"