-- function closures are powerful-- traditional fixed-point operator from functional programmingY=function(g)locala=function(f)returnf(f)endreturna(function(f)returng(function(x)localc=f(f)returnc(x)end)end)end-- factorial without recursionF=function(f)returnfunction(n)ifn==0thenreturn1elsereturnn*f(n-1)endendendfactorial=Y(F)-- factorial is the fixed point of F-- now test itfunctiontest(x)io.write(x,"! = ",factorial(x),"\n")endforn=0,16dotest(n)end