full adder in prolog code example
Example: full adder in prolog
halfadd(X, Y, Z, C) :-
Z is X xor Y,
C is X /\ Y.
fulladd(X, Y, C, Z, D) :-
halfadd(X, Y, H, J),
halfadd(H, C, Z, K),
D is J \/ K.
halfadd(X, Y, Z, C) :-
Z is X xor Y,
C is X /\ Y.
fulladd(X, Y, C, Z, D) :-
halfadd(X, Y, H, J),
halfadd(H, C, Z, K),
D is J \/ K.