plus(X,0,X).
plus(0,Y,0).
plus(s(X),Y,s(Z)):- plus(X,Y,Z).
multi(0,Y,0).
multi(s(0),Y,Y).
multi(s(X),Y,Z):- multi(X,Y,T), plus(Y,T,Z).
div(0,Y,0).
div(X,Y,Z):- quot(X,Y,Y,Z).
quot(0,s(Y),Z,0).
quot(s(X),s(Y),Z,T):-quot(X,Y,Z,T).
quot(X,0,s(Z),s(T)):- div(X,s(Z),T).
div(Z1,T,V):-div(X,Y,Z1),multi(Y,T,Z2),div(X,Z2,V).
