Sub topic 4
Parity as a Remainder of 2
This chapter assumes you know what an integer is, how to work with negative numbers, what divisibility and remainders mean, and how exponent notation works. It restates parity using remainders. That restatement gives you a single tool for sums, products, negatives, and consecutive integers, so you can stop memorizing separate rules.
The definition in remainder form
An integer n is even if dividing it by 2 leaves remainder 0. It is odd if dividing it by 2 leaves remainder 1. Every integer falls into exactly one of these two classes. In symbols:
- n is even when n = 2k for some integer k.
- n is odd when n = 2k + 1 for some integer k.
The remainder form says the same thing as these formulas. If n = 2k + 1, then dividing n by 2 gives quotient k and remainder 1.
The GRE usually phrases this as "n is divisible by 2" for even, and "n leaves a remainder of 1 when divided by 2" for odd. Both phrases describe the same classes.
Remainders are never negative
The remainder when dividing by 2 is always 0 or 1, even when the integer is negative. This matters because many learners compute remainders for negatives incorrectly.
Write a negative integer as 2k + r with r equal to 0 or 1:
- -4 = 2(-2) + 0, so the remainder is 0 and -4 is even.
- -3 = 2(-2) + 1, so the remainder is 1 and -3 is odd.
- -1 = 2(-1) + 1, so the remainder is 1 and -1 is odd.
- 0 = 2(0) + 0, so the remainder is 0 and 0 is even.
Notice that -3 is not "2(-1) - 1". That form gives a remainder of -1, which is outside the allowed range. The quotient is -2, not -1.
The Python % operator follows this convention for a positive divisor, so you can check any integer directly:
for n in (-4, -3, -1, 0, 1, 6, 7):
print(n, n % 2, "even" if n % 2 == 0 else "odd")Be careful when you use other languages or calculators. Some of them return a negative remainder for a negative dividend, for example -3 % 2 giving -1. For parity, only the question "is the remainder 0 or not?" matters, and that answer is the same everywhere.
Why the remainder view is useful
Because only the remainders 0 and 1 exist, you can treat each integer as one of two labels. Call even "0" and odd "1". The rules for sums and products then reduce to arithmetic on these two labels, with the result reduced to 0 or 1 by taking the remainder after dividing by 2.
The first code example in this tutorial prints exactly this table:
for a in (0, 1):
for b in (0, 1):
print(a, b, (a + b) % 2, (a * b) % 2)The output has four lines:
| a | b | (a + b) % 2 | (a * b) % 2 |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Read the third column as the parity of a sum. It is 1 (odd) only when exactly one addend is 1. Read the fourth column as the parity of a product. It is 1 (odd) only when both factors are 1.
Proving the rules with algebra
The table is a check on labels. The algebra below shows why it holds for every integer.
Let a = 2j + r and b = 2k + s, where r and s are each 0 or 1.
For the sum:
a + b = 2j + 2k + r + s = 2(j + k) + (r + s)
The first part is a multiple of 2, so it does not affect the parity. The parity of a + b is the parity of r + s. This is why the sum of two odd numbers (1 + 1 = 2) is even, since 2 is itself even.
For the product:
ab = (2j + r)(2k + s) = 4jk + 2js + 2kr + rs = 2(2jk + js + kr) + rs
Again the first part is a multiple of 2. The parity of ab is the parity of rs. Since r and s are 0 or 1, rs is 1 only when both are 1.
The same argument covers differences, because subtracting b is the same as adding -b, and -b has the same parity as b. (If b = 2k + s, then -b = 2(-k) - s, and -s has the same parity as s.)
A shortcut notation
When a problem gives a long expression, replace each variable with its parity label and simplify with the two small tables. This is sometimes called "mod 2 arithmetic". The sum table is:
| + | even | odd |
|---|---|---|
| even | even | odd |
| odd | odd | even |
The product table is:
| × | even | odd |
|---|---|---|
| even | even | even |
| odd | even | odd |
Treat the tables as a way to check your work. You can always rebuild them from remainders in a few seconds.
Worked example: a longer expression
Suppose x is odd and y is even. Is x² + 3xy + y odd or even?
- x is odd, so x² is odd × odd = odd.
- 3 is odd, x is odd, so 3x is odd. Then 3xy is odd × even = even.
- y is even.
- The sum is odd + even + even = odd.
In remainder terms: x = 1, y = 0, so x² + 3xy + y = 1 + 0 + 0 = 1, and the result is odd.
You can also confirm with real numbers. Take x = 3 and y = 4. Then 9 + 36 + 4 = 49, which is odd.
Mixed expressions: when the answer is not determined
A parity label works only when you know the label of every variable. If one variable could be either parity, the result may be undetermined.
Suppose x is an integer and you are asked about 2x + 1. The term 2x is a multiple of 2, so it is even whatever x is. Then 2x + 1 is even + odd = odd. The parity is determined even though x is unknown.
Now take x + 1 where x is an unknown integer. If x is even, x + 1 is odd. If x is odd, x + 1 is even. The parity is not determined.
In general, an expression has a determined parity when every unknown variable either appears only inside an even multiple or cancels out of the parity calculation. You can test whether a variable matters by flipping its label from 0 to 1 and checking whether the result changes.
def parity_expr(x, y):
return (x**2 + 3*x*y + y) % 2
for x in (0, 1):
for y in (0, 1):
print("x parity", x, "y parity", y, "result", parity_expr(x, y))This loop tests all four label combinations. The result changes when y changes, so the parity depends on y. It also changes when x changes (for example y = 1: x = 0 gives 1, x = 1 gives 1 + 3 + 1 = 5, so 1, and x = 0, y = 0 gives 0, x = 1, y = 0 gives 1). Running the code shows which combinations give odd results.
Common errors
- Counting a remainder of -1 for a negative odd number. The remainder is 1.
- Treating 0 as neither even nor odd. Zero is even, because it equals 2(0).
- Assuming that "not even" means "positive odd". Negative odd integers such as -5 are odd.
- Concluding that an expression is odd because it "looks odd". Replace variables with labels and compute.
- Using parity results for non-integers. Parity applies only to integers. The number 2.5 is neither even nor odd, and a problem that does not say a variable is an integer does not let you apply these rules.
A diagram of the classification
The diagram below shows how any integer is sorted by its remainder when divided by 2.
Using remainders on GRE questions
A common GRE question asks for the remainder of a sum or product when divided by 2, or equivalently asks whether the result is even. The remainder view lets you answer without large calculations.
For example, what is the parity of 1,001 × 2,347 + 8,000? Both 1,001 and 2,347 are odd, so their product is odd. 8,000 is even. Odd + even = odd. You never multiply the large numbers.
Another example: if n is an integer, is n(n + 1) even or odd? Whatever parity n has, n + 1 has the opposite parity, so one factor is even and the product is even. In labels, the pair is (0, 1) or (1, 0), and both give a product of 0. A later chapter develops this idea for consecutive integers.
Exercise
Let p be an odd integer and q be an even integer. Use remainders when dividing by 2 to decide the parity of p² + pq + q² + 1. Then check your answer with p = 5 and q = 2.
Show answer
Use labels p = 1, q = 0. Then p² = 1, pq = 0, q² = 0, and the constant 1 is odd. The sum is 1 + 0 + 0 + 1 = 2, which has remainder 0, so the expression is even. Check: 25 + 10 + 4 + 1 = 40, which is even.
Exercise
Find the remainder when -7 is divided by 2, written in the form -7 = 2k + r with r equal to 0 or 1. Is -7 even or odd?
Show answer
-7 = 2(-4) + 1, so k = -4 and r = 1. The remainder is 1, so -7 is odd.
Exercise
A question says "x is a number and 2x is even." Can you conclude that x is even? Explain with a counterexample.
Show answer
No. Parity applies only to integers. If x = 1.5, then 2x = 3, which is odd, so that choice does not work, but x = 2.5 gives 2x = 5, also odd. A valid counterexample uses an integer that is odd with the statement "2x is even": x = 3 gives 2x = 6, which is even, and x = 3 is odd. Any integer x makes 2x even, so the fact that 2x is even tells you nothing about the parity of x.