Factorial in Oz

Example for versions Mozart 1.4.0

This example uses iterative factorial definition. Compile using ozc -x <filename>.

functor
 
import
   Application System

define 

local
   F
in
   F = {NewCell 1}
   for I in 0..16 do
       {System.showInfo {Append {Append {Int.toString I} "! = "} {Int.toString @F}}}
       F := (I+1) * @F
   end
   {Application.exit 0}
end

end