Factorial in Euphoria

Example for versions Euphoria v3.1.1, Euphoria v4

This example uses iterative factorial definition.

function factorial(integer n)
  atom result = 1

  if n < 1 then
    return 1
  end if

  for i = 2 to n do
    result *= i
  end for

  return result
end function

for i = 0 to 16 do
 printf(1, "%d! = %d\n", {i, factorial(i)})
end for