|
excellent ! (note that your did not include the function header "function f(x)" and trailer "end" and the code "=x" to print the result on the Lua console).
It works because the range from 0 to 395 is small enough and it assumes that math.random() will return an exact value.This can create an infinite loop if this condition x*x=C is never reached exactly, because:- random() will not explore all the possible bits, as random() does not return all the possible values for the 52 bits of numbers in (0,1).- even if you have the best approximation possible of x, x^x=C may still be wrong (and there's no upper bound of the relative error on the value of x).