lua-users home
lua-l archive

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



> On Apr 4, 2019, at 12:03 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 
> Op Do. 4 Apr. 2019 om 01:14 het Albert Chan <albertmcchan@yahoo.com> geskryf:
>> 
>> Comes across a fun math puzzle. :-)
>> 
>> Design a function cin(X), such that cin(cin(cin(X))) = sin(X)
>> 
>> cin(X) must be smooth function, and at least 10 digits accurate.
>> 
>> In other words, cin(cin(cin(X))) / sin(X) = 1.00000 00000
>> 
>> What is the value of cin(2.019) ?
> 
> Since you post it on this list, one assumes that the calculation musr
> be done in Lua :-)
> 
> Am I allowed the luxury of requiring luafft (available from LuaRocks)?
> 

There is of course the “cheat” answer, which highlights how careful you need to be when setting puzzles:

do
	local c = 0
	function cin(x) c = c + 1; return ((c % 3) == 0) and sin(x) or x end
end

—Tim