lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Le jeu. 27 juin 2019 à 18:30, Philippe Verdy <verdy_p@wanadoo.fr> a écrit :
i.e. it's enough to pass to the recursion call the value x^x*(1+(log2(x)*x<1024 and 1 or 0))
correction: pass the value x^x*(x*log2 x<1024 and 1 or 0)
So you get an anwer:
f f f f f f(x^x*(x*log2 x<1024 and 1 or 2))

I think that (x*log2 x<1024 and 1 or 2) can be implemented using an integer division to remove the "and"/"or":
(x*math.log2 x div 512) 

And we get something like:
f f f f f f(x^x*(x*math.log2 x div 512))

function f(x) return
x^x*(x*math.log2 x div 512)
end

and to get the value just call "f f f f f f x"