lhf*_*lhf 49
使用math.fmod(x,y)哪个做你想要的:
返回x除以x的除法的余数,将商舍入为零.
http://www.lua.org/manual/5.2/manual.html#pdf-math.fmod
nin*_*ded 26
它并不理想,但根据Lua 5.2参考手册:
a%b == a - math.floor(a/b)*b
小智 5
for i = 1, 100 do
if (math.mod(i,2) == 0) then
print( i .. " is divisible.")
end
end
Run Code Online (Sandbox Code Playgroud)