Factorial in Picat
Example for versions
Picat 0.7
This example implements recursive factorial definition using a function.
factorial(0) = 1.
factorial(N) = F, N > 0 => F = N * factorial(N - 1).
main =>
foreach (I in 0 .. 16)
writef("%w! = %w\n", I, factorial(I))
end.
Comments
]]>blog comments powered by Disqus
]]>