factorial(0, 1).
factorial(N, Factorial) :- M is N – 1, factorial(M, M_Factorial), Factorial is N * M_Factorial.

recursion in first order logic.