fork(46) download
  1.  
  2. factorial(0, 1).
  3. factorial(N, F) :- N > 0, Prev is N -1, factorial(Prev, R), F is R * N.
  4.  
  5. :- factorial(5,X), writeln(X).
Success #stdin #stdout #stderr 0.02s 6204KB
stdin
Standard input is empty
stdout
120
stderr