I\'m having trouble understanding the following factorial program
fact1(0,Result) :- Result is 1. fact1(N,Result) :- N > 0, N1 is N-1, fac
factorial(1, 1). factorial(N, Result) :- M is N - 1, factorial(M, NextResult), Result is NextResult * N.
A simple way :
factorial(N, F):- N<2, F=1. factorial(N, F) :- M is N-1, factorial(M,T), F is N*T.