I'm having trouble writing a recursive program that finds the Factorial of a number that is the output of another fucntion (exp bar)
here's my program for (exp bar)
exbar(0, 0, 0, _) :-
write('Error'),
nl.
exbar(X, Y, 0, 1) :-!.
exbar(X, Y, 1, R) :-
R is 2*X +Y.
exbar(X, Y, N, R) :-
N1 is N-1,
exbar(X, Y, N1, R1),
R is R1 * (2*X +Y).
that program works fine
but here is my program for factbar
factbar(_, _, _, 0, 1):-!.
factbar(X, Y, N, F):-
exbar(X, Y, N, R),
M1 is R-1,
factbar(X, Y, N, F1),
F is M*F1.
this however, always gives me errors so i know its not correct
Any help would be appreciated