Parity

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).

A different type of parity of an integer is defined as the sum of the bits in binary representation, i.e., the digit count , computed modulo 2. So, for example, the number has two 1s in its binary representation and hence has parity 2 (mod 2), or 0. The parities of the first few integers (starting with 0) 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 parity is given by

(1)

The constant generated by interpreting the sequence of parity digits as a binary fraction is called the Thue-Morse constant.

The parity function obeys the sum identity

(2)

for any . For example, for and ,