length(0,[]). length(N,[_|L]) :- length(M,L), N is M+1.Please define predicates member/2, fac/2, fib/2, and gcd/3 analogously.
f(1,one). f(s(1),two). f(s(s(1)),three). f(s(s(s(X))),N) :- f(X,N).How does Prolog answer to the following questions?
fac(X,N) :- fac(X,N,1). fac(0,A,A). fac(X,N,A) :- X > 0, A1 is A * X, X1 is X - 1, fac(X1,N,A1).Please define the predicates from exercise 5 and predicate fib/2 from exercise 1 using this technique. (Note: The third argument of of fac/3 is called accumulator.)