Factorial in Picat

Example for versions Picat 0.7

This example implements recursive factorial definition using a predicate.

factorial(0, F) => F = 1.
factorial(N, F), N > 0 => factorial(N - 1, F1), F = N * F1.

main =>
     foreach (I in 0 .. 16)
          factorial(I, F),
          writef("%w! = %w\n", I, F)
     end.