Brilli the Ant states that "Given any N integers, we can always find two distinct integers whose difference of squares is a multiple of 1000."
What is the smallest integer value of N that would make the statement true?
Details and assumptions
Clarification: You are given a random collection of N integers. You are not given the integers from 1 to N .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Nicely done!
The Jon H.'s comment below is very much worth reading too.
Here is a way to count the number of squares modulo 125.
We want to find the number of residues that n 2 ( m o d 1 2 5 ) can take on. If n is divisible by 5, then let n = 5 a . Then n 2 ≡ 2 5 a 2 ( m o d 1 2 5 ) . The only residues of the form 2 5 a 2 ( m o d 1 2 5 ) are 0, 25, and 100. (It suffices to check 0 ≤ a ≤ 4 .)
Otherwise, n is relatively prime to 5. Suppose that there are two distinct integers n and m , where 0 ≤ n , m ≤ 1 2 4 , that are relatively prime to 5 such that n 2 ≡ m 2 ( m o d 1 2 5 ) . Then ( n + m ) ( n − m ) ≡ 0 ( m o d 1 2 5 ) .
If both n + m and n − m are divisible by 5, then ( n + m ) + ( n − m ) = 2 n is divisible by 5, which means that n is divisible by 5, contradiction. Therefore, at most one of n + m and n − m is divisible by 5. But their product is divisible by 125, which means exactly one of them is divisible by 125.
Since 0 ≤ n , m ≤ 1 2 4 and n and m are distinct, n − m cannot be divisible by 125. Hence, n + m is divisible by 125. But 0 < n + m < 2 5 0 , so n + m = 1 2 5 . Thus, n 2 ≡ m 2 ( m o d 1 2 5 ) implies that m = 1 2 5 − n .
This shows that if we list the ϕ ( 1 2 5 ) = 1 0 0 residues n 2 ( m o d 1 2 5 ) , where 1 ≤ n ≤ 1 2 4 and n is relatively prime to 5, in order, then the first 1 0 0 / 2 = 5 0 residues are all distinct, but then the last 50 residues are the same as the first 50 residues, in reverse order.
Therefore, the number of squares modulo 125 is 3 + 5 0 = 5 3 .
Log in to reply
This is very nice!
Another way to see that exactly half of the residues of 125, that are coprime to 5, are quadratic residues is to use the existence of the multiplicative generator (such residue g that 1 , g , g 2 , . . . , g 1 1 9 are all distinct). This is true for all odd prime powers, and is a very useful theorem. The proof is definitely more complicated than the Jon H.'s argument.
How do you count the number of possible values of x^2 mod 125?
Log in to reply
one by one? :)
Log in to reply
Zi Song, do you have a quick way to do it? How did you do it? I used excel's modulo function to bash it...
Log in to reply
@Russell Few – Everything else of his solution is fine though...
@Russell Few – Counting the number of quadratic residues mod 1 2 5 ? There are 6 2 squares (excluding 0 2 = 0 ), so it is possible by listing/simple programming/your way(excel)/the comment above. If you're concerned about speed, then python should be the fastest. But the best way is what Jon H. posted.
Log in to reply
@Zi Song Yeoh – Idid this by difference of squares and modulo.
So, I couldn't find a really good way of doing it, but I wound up using Hensel's lemma for x^2-k=0 mod 5 to solve mod 25 and then mod 125. It wasn't pleasant, but it definitely could have been worse. Still, I'd be interested in knowing if there is a better way.
Haha why use the Chinese remainder theorem if you have all the same to count the distinct values of x^2 mod 125 ? Count the values of x^2 mod 1000 !
Log in to reply
That would be much more tedious. Counting quadratic residues modulo 8 does not involve much casework, and Jon H.'s comment shows a very elegant method of calculating the quadratic residues ( m o d 1 2 5 ) .
There are 1 5 9 different remainders, modulo 1 0 0 0 , that squares can give. We only need to check this for numbers from 0 to 2 5 0 , since x 2 , ( 5 0 0 − x ) 2 and ( 5 0 0 + x ) 2 all give the same remainder modulo 1 0 0 0 .
The fact that 1 6 0 numbers are bound to provide at least two squares which have the same remainder modulo 1 0 0 0 , and hence whose difference is a multiple of 1 0 0 0 , is now an elementary application of the Pigeon-Hole Principle.
Nicely done!
Did you just compute all the squares from 0-250 by brute force?
I like your solution, Mark.
For me, I considered negative integers as well. I didn't think 0 was a "multiple of 1000", so if 1 was in the set, -1 could be too. Thus I doubled the 159, and added 1 for the Pigeon-Hole principle.
I think it would have been clearer to state "positive integers" if that was what was meant.
Log in to reply
It does not matter if you include negative integers. x 2 and ( − x ) 2 have the same remainder modulo 1 0 0 0 , or any other base.
We need to consider the quadratic residues m o d 1 0 0 0 . If there are q of these, then by the pigeonhole principle a set of size q + 1 , and no smaller, must contain two integers with the same quadratic residue m o d 1 0 0 0 and therefore their difference is a multiple of 1000.
Let q ( X ) be the number of quadratic residues m o d X . From the Chinese Remainder Theorem we can prove that if M , N are coprime then q ( X ) = q ( M ) q ( N ) . So q ( 1 0 0 0 ) = q ( 2 3 ) q ( 5 3 ) = 3 × 5 3 = 1 5 9 and the answer we want is 1 6 0 .
q ( 2 3 ) can easily be checked by inspection to be 3 because the residues are 0 , 1 , 4 .
q ( 5 3 ) is trickier to explain. Gauss found the general solution for powers of an odd prime in Disquisitions Arithmeticae articles 101 and 102.
I didn't prove it myself from scratch, but took hints from Gauss's proof.
Any member of the integers m o d 5 3 can be written in one of these forms: a , 5 a , or 5 2 a where a is coprime to 5 . We'll look at those cases separately.
Case 1: If we have x 2 ≡ a m o d 5 3 y 2 ≡ a m o d 5 3 then x 2 − y 2 ≡ 0 m o d 5 3 so 5 divides ( x + y ) ( x − y ) .
5 can't divide both of those, otherwise it would divide their sum 2 x , contradicting that x 2 is coprime to 5 . Therefore either x ≡ y or x ≡ − y . Since we already know that − a is a quadratic residue m o d p iff a is, we conclude that a is a quadratic residue m o d p n iff it is one m o d p .
Case 2: x 2 ≡ 5 a m o d 5 3 . Suppose there is s such that 5 a ≡ s 2 m o d 5 3 . Since 5 ∣ s 2 , then 5 ∣ s . So 5 2 ∣ s 2 , so 5 ∣ a , contradicting the defintion of a . Conclusion: 5 a is never a residue.
Case 3: x 2 ≡ 5 2 a m o d 5 3 . If a is a quadratic residue m o d 5 3 then a = s 2 for some s , and then 5 2 a = ( 5 s ) 2 , so 5 2 a is also a quadratic residue.
And if a is not a quadratic residue m o d 5 3 then there cannot be a solution s to 5 2 a ≡ s 2 m o d 5 3 otherwise 5 2 would divide s 2 .
Conclusion: in this case, 5 2 a is a residue iff a is.
Totalling the three cases and using the fact that the quadratic residues m o d 5 are { 0 , − 1 , + 1 } : Case 1 gives us all numbers of the form 5 k ± 1 m o d 5 3 , of which there are 2 5 ∗ 2 = 5 0 . Case 3 gives us 0 , 5 2 , − 5 2 which is 3 cases, for a sum of 5 0 + 3 = 5 3 .
The general rules are that the number of residues mod p is ( p + 1 ) / 2 ; and if k < n then if k is odd, p k a is not a residue mod p n ; and if k is even, then p k a is a residue iff a is.
Let k be the number of quadratic residues. If we have k + 1 integers, then by the pigeonhole principle, there must be 2 whose square are congruent in modulo 1000 (since there are a total of k possible residues). There is a total of 159 quadratic residues so we need 160 numbers.
Problem Loading...
Note Loading...
Set Loading...
The problem reduces to being sure that you have two numbers, a and b, in the set such that 1000|(a^2-b^2) which implies that a^2=b^2 mod 1000. Note that 1000= (2^3)*(5^3).
x^2 has 3 possible values mod 8.
x^2 has 53 possible values mod 125.
By the Chinese remainder theorem, x^2 has 3 × 5 3 = 1 5 9 possible values mod 1000. Thus, by the pigeonhole principle, in a set of 160 integers, at least two will exist such that their squares are congruent mod 1000.