31 posts
Posted 08 September 2012 - 12:59 PM
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
992 posts
Posted 08 September 2012 - 01: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
1688 posts
Location
'MURICA
Posted 08 September 2012 - 04: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
31 posts
Posted 09 September 2012 - 09:13 AM
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
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!! :D/>/>