Factorial
Factorial. factorial_of(0,1). factorial_of(N,Ans) :-N>0, N1 is N-1, % “ is ” eval numerical expressions like N-1. factorial_of(N1,PrevAns), Ans is PrevAns*N. ?- factorial_of(5,Ans). ?- factorial_of(3,6). ?-factorial_of(X,120). Integer Operation.
479 views • 27 slides