Just tried to execute a small Lua script, but unfortunately I’m doing something wrong. I’ve no more ideas what the fault might be.
function checkPrime( n ) for i = 2, n-1, 1 do if n % i == 0 then return false end end return true end
The interpreter says:
lua: /home/sebastian/luatest/test.lua:3: `then' expected near `%'
I think it’s not a big thing and perhaps it’s quite clear what is wrong. But somehow I cannot see it at the moment.
There is probably some version problem, check your version of lua. The usage of ‘%’ as an infix operator for modulo can only be used in Lua 5.1, in 5.0 it is not supported yet. Try using
math.modinstead:Edit: Also note that in 5.1,
math.modstill exists, but it has been renamed tomath.fmod. For now, the old name still works, but support will probably be removed in future versions.