'is odd' / 'is even' notation I would like to write down that $x$ is $true$ if $n$ is odd and $false$ if $n$ is even.
So far I made this up:
$x = ( n - 2⌊\frac{n}{2}⌋ = 1)$
However, I was wondering whether this can be expressed this way at all, and whether there is a general notation that means 'is odd' or 'is even'.
Thanks for any hints on this.
 A: I'm not sure what it means to define "x" as being "true" or "false": boolean variables as a data type are not much used in mathematics. If you want 1 or 0, then there is a notation called Iverson bracket, popularized by Knuth (and others) in the book Concrete Mathematics and elsewhere, that uses square brackets for what you want: [P] is the variable that is 1 if P is true and 0 otherwise. Thus you could write any of:


*

*$x = \left[n - 2\lfloor\frac{n}{2}\rfloor = 1\right]$ (almost what you wrote)

*$x = \left[ n \equiv 1 \mod 2\right]$ or 

*$x = \left[2|n\right]$ or simply,

*$x = [n\text{ is odd}]$, which is best. (Even better would be to write "x is 1 if n is odd and 0 otherwise", but presumably you don't want to write that for some reason.)


In some areas especially of probability, they use a notation like $1_{\text{{n is odd}}}$ or whatever, with the condition written as a subscript to 1.
A: An integer $x$ is odd if and only if $x\equiv 1\pmod 2$, that is the remainder when divided by $2$ is nonzero.
Similarly, an integer $x$ is even if and only if $x\equiv 0\pmod 2$.
Edit: after the small discussion in the comments I have decided to add this -
If you want $x$ to have a truth value of whether or not an integer $n$ is even, then $x=(n\equiv 0\pmod 2)$ is a good way to write that. As the expression $n\equiv 0\pmod 2$ is true if and only if $n$ is even.
A: 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".
A: There's a standard notation $a|b$ that means "a divides b", or more precisely "$\exists c : ac = b$" (in the context of a particular ring). So "n is even" can be written concisely as "$2|n$".
A: Define $$x \iff n \text{ is odd}$$
then $x$ is true when $n$ is odd and false when n is even.

This is real mathematics you don't have to turn everything into brackets and 5s and squiggly things that make no sense.
