Lua replacement for the % operator

前端 未结 6 1713
臣服心动
臣服心动 2020-12-30 19:39

I want to check, if a number is divisible by another number:

for i = 1, 100 do
    if i % 2 == 0 then
        print( i .. \" is divisible.\")
    end
end
         


        
6条回答
  •  抹茶落季
    2020-12-30 20:11

    Use math.fmod, accroding lua manual math.mod was renamed to math.fmod in lua 5.1.

提交回复
热议问题