Previous, Math 511 Home, Contents, Next

Repetitions of Squares

On Friday we examined tables of squares in Zn for different values of n. For example, in Z15 you get the following table of squares.
n 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
n2 0 1 4 9 1 10 6 4 4 6 10 1 9 4 1

The sequence of squares of non-zero elements is palindromic as we proved all such sequences must be. But unlike sequences of squares in fields, there are some repetitions besides the required plus/minus pairs, which means some numbers have more than two square roots. For example, 1 has four square roots, ±1 and ±4. The table of squares for Z10, on the other hand, doesn’t have any repetitions from 0 to 5 and so no numbers have more than two square roots (mod 10).

n 0 1 2 3 4 5 6 7 8 9
n2 0 1 4 9 6 5 6 9 4 1

After working out the tables of squares for Z20 through Z30, we discovered that there were no repetitions of the squares from 0 to n/2 for Z22, Z23, Z26, and Z29, while there were repetitions for Z20, Z21, Z24, Z25, Z27, Z28, and Z30. Examining this we conjectured that

The first rule is illustrated by the fact that Z10 has no repetitions from 0 to 5 while Z15 has repetitions with both 12 = 1 and 42 =1, and both 22 = 4 and 72 = 4. Of course, 10 is twice a prime while 15 is not. We had proved that there couldn’t be any repetitions for Zp with p prime earlier, since such Zp are fields. That it also worked for Z2p, which aren’t fields, was a little surprising. Trying to understand why this should be true, we then looked at when repetitions occurred in the other cases. For example, in Z15 we have repetitions for 1 and 4 and for 2 and 7. After some thought, it was noted that 4 + 1 = 5 and 4 - 1 = 3, and 3 ´ 5 = 15. Similarly, 7 + 2 = 9 and 7 - 2 = 5, and 5 ´ 9 = 45 = 3 ´ 15. After a little bit of algebra, we observed that a2 = b2 (mod n) if and only if a2 - b2 = 0 (mod n) which happens if and only if (a + b)(a - b) = 0 (mod n). From this relationship we can determine a number of things as illustrated in the next several examples.

Example: Find a and b with a ¹ ±b but a2 = b2 (mod 253).

We first factor 253 to get 253 = 11 ´ 23. So we look for a and b with a + b = 23 and a - b = 11. Doing the algebra, we get a = (23 + 11)/2 = 17 and b = (23 - 11)/2 = 6. We check 172 = 289 = 36 = 6(mod 253).

Example: Factor 10573 given the hint that 4062 = 792 (mod 10573).

From the given, we can conclude that (406 + 79) ´ (406 - 79) = 0 (mod 10573). We check that 485 ´ 327 = 158595, and, dividing by 10573, we get 108595 = 15 ´ 10573, so 485 ´ 327 = 15 ´ 10573. Now we factor 485 = 5 ´ 97 and 327 = 3 ´ 109 (this is easier than factoring 10573 since the numbers are much smaller). Plugging these factors into our previous equation we get 5 ´ 97 ´ 3 ´ 109 = 15 ´ 10573, and canceling out 15 from each side leaves us with the factorization of 10573 = 97 ´ 109.

These are very useful examples, for they suggest how looking for repetitions of squares can lead to factoring large numbers, and, in fact, these ideas are used in various practical algorithms for factoring. Factoring numbers is the key to breaking RSA public key encryption so such applications are quite important. We will study them in the next lectures. But we still have to finish the question that started our considerations of these ideas in this lecture, why are there no repetitions for Z2p?

Theorem: If 0 £  a,b £  p (with a ¹  b), then a2 ¹  b2 (mod 2p).

Proof: Suppose a2 = b2 (mod 2p). Then (a + b)(a - b) = 0 (mod 2p), which means (a + b)(a - b) = y ´ 2 ´ p for some y. Since p is a prime, in order for p to be a factor of the right-hand side it must be a factor of one of the terms on the left-hand side. Due to the restriction that 0 £ a,b £ p, it follows that a + b = p. This implies that a - b = 2 ´ y. Now when we use algebra to solve for a and b, we get a = (p + 2y)/2 and b = (p - 2y)/2. But since p is odd and 2y is even, neither a nor b are integers, so there can be no such a, b pair in Z2p.

We haven’t proved that there always will be repetitions for the other cases, but that isn’t hard, just tedious. Using the techniques of the first example you can always find a repetition. You just have to go through the details to check that by appropriat e choices of factors you can always get a and b to turn out to be integers rather than half-integers.


Please report any problems with this page to bennett@math.ksu.edu
©1998 Andrew G. Bennett