I don’t actually have a problem, I’m asking this because I’m courious
You can take the modulo of a number, which provides its remainder, if the remainder of % 2 is 0, than your number is even, here is a quick example:
number = 5
if number % 2 != 0:
print(“The number is odd”)
else:
print(“The number is even”)
That doesn’t work, I get either 0.02 (1) or 0.04 (2)
Not to mention the many syntax errors. Looks like it was written in C#
In Lua, it would be like this
local number = 5
if number % 2 ~= 0 then
print("The number is odd")
else
print("The number is even")
end
And yes, it does actually work
I don’t know what I’m doing wrong, also thanks for the solution!
Also, it gives me the result when I type 5%2 in the search bar, but not in the calculator, Google is broken…
Google calculator’s issue is that it multiplies it by two for some reason, no matter what you do. Bing’s calculator and the TI-84 I have in my backpack work normally lol
You are calculating 5 percent times 2, which result in 10 percent, or 0.1.
You are suppose to type 5 % 2
.
Based on the topic title and description, no.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.