The parity of an integer is its attribute of being even or odd. Thus, it can be said that 6 and 14 have the same parity (since both are even), whereas 7 and 12 have opposite parity (since 7 is odd and 12 is even).
The binary parity
of a nonnegative integer
is the remainder of its binary digit sum
on division by 2. The sum
of the bits
in its binary representation is the digit
count
. For example,
has two 1s in its binary
representation and hence has binary parity 0. The binary parities of the first few
nonnegative integers are therefore 0, 1, 1,
0, 1, 0, 0, 1, 1, 0, 0, ... (OEIS A010060),
as summarized in the following table.
| binary | parity | binary | parity | ||
| 1 | 1 | 1 | 11 | 1011 | 1 |
| 2 | 10 | 1 | 12 | 1100 | 0 |
| 3 | 11 | 0 | 13 | 1101 | 1 |
| 4 | 100 | 1 | 14 | 1110 | 1 |
| 5 | 101 | 0 | 15 | 1111 | 0 |
| 6 | 110 | 0 | 16 | 10000 | 1 |
| 7 | 111 | 1 | 17 | 10001 | 0 |
| 8 | 1000 | 1 | 18 | 10010 | 0 |
| 9 | 1001 | 0 | 19 | 10011 | 1 |
| 10 | 1010 | 0 | 20 | 10100 | 0 |
A generating function for binary parity is given by
|
(1)
|
for . The constant
generated by interpreting the sequence of binary parity
digits as a binary fraction
is called the Thue-Morse
constant.
The binary parity function obeys the sum identity
|
(2)
|
for any nonnegative integer and any complex number
. For example, for
and
,
|
(3)
|