bin(X,0,s(0)).
bin(0,s(Y),0).
bin(s(X),s(Y),Z):- bin(plus(X,s(Y)),Z1),bin(X,Y,Z2), p(plus(Z1,Z2),Z).
p(plus(X,0),X).
p(plus(X,s(Y)),s(Z)):- p(plus(X,Y),Z).