This is what I tried to convert Octal number to binary. What I wanted to do was to find the remainder of the given octal number when divided by 10 to get each digit and convert that digit to 3 bit binary. But this code is not producing any output. Please help on this. Thanks in advance.
convert_bin(0, '0').
convert_bin(1, '1').
convert_bin(N, B) :-
N > 1,
X is N mod 2,
Y is N // 2,
convert_bin(Y, B1),
atom_concat(B1, X, B).
convert_oct(N, O) :-
X is N mod 10,
convert_bin(X, B),
Y is N // 10,
convert_oct(Y, O1),
atom_concat(O1, B, O).