It seems as though you're coming at this from a programming perspective, ie you want to write a function boolean isEven(int n)
which returns true
if n
is even and false
if it is odd.
The simplest method would be to check the final bit of the binary representation of n
. If that bit is a 0 you return true
, and if it is a 1 you return false
.
Edit (as per comment below): You can use indicator functions defined as $1[A]=1$ if $A$ is true and $1[A]=0$ if $A$ is false, meaning that you might want to write
$$x = 1[n\textrm{ is odd}]$$
or perhaps
$$x := 1[n\textrm{ is odd}]$$
where $:=$ is mathematical notation understood to mean "is defined to be".