Hey I need a program to know if a number is devisible by 3 so I need to know how to get a computer to detect if an answer is a whole number eg. 24/3=8 so true. 13/3=4.33333333333 so false
Lua math - whole numbers
Started by Heroj04, Sep 08 2012 11:59 AM
3 replies to this topic
#1
Posted 08 September 2012 - 11:59 AM
#2
Posted 08 September 2012 - 12:45 PM
if math.fmod(7,3) == 0 then
print("there is no remainder")
else
print("there is a remainder")
end
this can tell you if it divided by three correctly alter the numbers in the math.fmod() section and watch the results. if it divided it will return 0 if not it will return something else
#3
Posted 08 September 2012 - 03:49 PM
Just a side note, math.fmod can be replaced with the % sign, in which the above example can be performed as such:
if 7%3 == 0 then
print("there is no remainder")
else
print("there is a remainder")
end
#4
Posted 09 September 2012 - 08:13 AM
BigSHinyToys, on 08 September 2012 - 12:45 PM, said:
if math.fmod(7,3) == 0 then
print("there is no remainder")
else
print("there is a remainder")
end
this can tell you if it divided by three correctly alter the numbers in the math.fmod() section and watch the results. if it divided it will return 0 if not it will return something else
Kingdaro, on 08 September 2012 - 03:49 PM, said:
Just a side note, math.fmod can be replaced with the % sign, in which the above example can be performed as such:
if 7%3 == 0 then
print("there is no remainder")
else
print("there is a remainder")
end
thanks these both worked this will help me alot!!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











