I need help with my mathematical formula in python. I want to fix it because it’s returning -1 for some values and it’s not properly returning 0 and 1 when n is the right number.
All I’m trying to do is create a mathematical formula I can use in python (only addition and subtraction) that can tell when the formula (n % 3) is 0. Based on the value of n it will return 0 if the answer isn’t 0 or 1 if it’s 0.
My code is:
n = 10
result = 1 - ((n % 3) + ((n % 3) - 1) + ((n % 3) - 2))
print(result)
The result should return 1 and 0 depending on if it’s true or not so I can use this code properly.