Is there any function that returns if the number is odd or even?
I want to use it like this:
If odd(i) then print("number %i is odd")
else ("number %i is even") end
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Is there any function that returns if the number is odd or even?
I want to use it like this:
If odd(i) then print("number %i is odd")
else ("number %i is even") end
found myself ))))))
if math.mod(i, 2) == 0 then print("even") end
1 2 3 4 5 6 | local test=999 if test%2 == 0 then print "EVEN" else print "ODD" end |
1 2 3 4 5 | if i % 2 == 0 then print (i, " is even") else print (i, " is odd") end |
try this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | local function odd(num) if num % 2 == 0 then return false else return true end end local i = 9 if odd(i) then print("number ".. i .." is odd") else print("number ".. i .." is even") end |