Lucky pick

Brilli the Ant states that "Given any N 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 N that would make the statement true?

Details and assumptions

Clarification: You are given a random collection of N N integers. You are not given the integers from 1 to N N .


The answer is 160.

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.

4 solutions

Conner Davis
Oct 7, 2013

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 × 53 = 159 3 \times 53=159 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.


Moderator note:

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 125 ) n^2 \pmod{125} can take on. If n n is divisible by 5, then let n = 5 a n = 5a . Then n 2 25 a 2 ( m o d 125 ) . n^2 \equiv 25a^2 \pmod{125}. The only residues of the form 25 a 2 ( m o d 125 ) 25a^2 \pmod{125} are 0, 25, and 100. (It suffices to check 0 a 4 0 \le a \le 4 .)

Otherwise, n n is relatively prime to 5. Suppose that there are two distinct integers n n and m m , where 0 n 0 \le n , m 124 m \le 124 , that are relatively prime to 5 such that n 2 m 2 ( m o d 125 ) . n^2 \equiv m^2 \pmod{125}. Then ( n + m ) ( n m ) 0 ( m o d 125 ) . (n + m)(n - m) \equiv 0 \pmod{125}.

If both n + m n + m and n m n - m are divisible by 5, then ( n + m ) + ( n m ) = 2 n (n + m) + (n - m) = 2n is divisible by 5, which means that n n is divisible by 5, contradiction. Therefore, at most one of n + m n + m and n m 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 0 \le n , m 124 m \le 124 and n n and m m are distinct, n m n - m cannot be divisible by 125. Hence, n + m n + m is divisible by 125. But 0 < n + m < 250 0 < n + m < 250 , so n + m = 125 n + m = 125 . Thus, n 2 m 2 ( m o d 125 ) n^2 \equiv m^2 \pmod{125} implies that m = 125 n m = 125 - n .

This shows that if we list the ϕ ( 125 ) = 100 \phi(125) = 100 residues n 2 ( m o d 125 ) n^2 \pmod{125} , where 1 n 124 1 \le n \le 124 and n n is relatively prime to 5, in order, then the first 100 / 2 = 50 100/2 = 50 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 + 50 = 53 3 + 50 = 53 .

Jon Haussmann - 7 years, 8 months ago

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 g that 1 , g , g 2 , . . . , g 119 1, g, g^2,...,g^{119} 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.

Alexander Borisov - 7 years, 8 months ago

How do you count the number of possible values of x^2 mod 125?

Russell FEW - 7 years, 8 months ago

Log in to reply

one by one? :)

Zi Song Yeoh - 7 years, 8 months ago

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

Russell FEW - 7 years, 8 months ago

Log in to reply

@Russell Few Everything else of his solution is fine though...

Russell FEW - 7 years, 8 months ago

@Russell Few Counting the number of quadratic residues mod 125 125 ? There are 62 62 squares (excluding 0 2 = 0 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.

Zi Song Yeoh - 7 years, 8 months ago

Log in to reply

@Zi Song Yeoh Idid this by difference of squares and modulo.

Zi Song Yeoh - 7 years, 8 months ago

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.

Conner Davis - 7 years, 8 months ago

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 !

Louis Abraham - 7 years, 8 months ago

Log in to reply

That would be much more tedious. Counting quadratic residues modulo 8 8 does not involve much casework, and Jon H.'s comment shows a very elegant method of calculating the quadratic residues ( m o d 125 ) \pmod{125} .

Sreejato Bhattacharya - 7 years, 8 months ago
Mark Hennings
Oct 8, 2013

There are 159 159 different remainders, modulo 1000 1000 , that squares can give. We only need to check this for numbers from 0 0 to 250 250 , since x 2 x^2 , ( 500 x ) 2 (500-x)^2 and ( 500 + x ) 2 (500+x)^2 all give the same remainder modulo 1000 1000 .

The fact that 160 160 numbers are bound to provide at least two squares which have the same remainder modulo 1000 1000 , and hence whose difference is a multiple of 1000 1000 , is now an elementary application of the Pigeon-Hole Principle.

Moderator note:

Nicely done!

Did you just compute all the squares from 0-250 by brute force?

Matt McNabb - 7 years, 8 months ago

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.

Steven Perkins - 7 years, 8 months ago

Log in to reply

It does not matter if you include negative integers. x 2 x^2 and ( x ) 2 (-x)^2 have the same remainder modulo 1000 1000 , or any other base.

Mark Hennings - 7 years, 8 months ago
Matt McNabb
Oct 11, 2013

We need to consider the quadratic residues m o d 1000 \mod 1000 . If there are q q of these, then by the pigeonhole principle a set of size q + 1 q+1 , and no smaller, must contain two integers with the same quadratic residue m o d 1000 \mod 1000 and therefore their difference is a multiple of 1000.

Let q ( X ) q(X) be the number of quadratic residues m o d X \mod X . From the Chinese Remainder Theorem we can prove that if M , N M,N are coprime then q ( X ) = q ( M ) q ( N ) q(X) = q(M)q(N) . So q ( 1000 ) = q ( 2 3 ) q ( 5 3 ) = 3 × 53 = 159 q(1000) = q(2^3) q(5^3) = 3 \times 53 = 159 and the answer we want is 160 \boxed{160} .

q ( 2 3 ) q(2^3) can easily be checked by inspection to be 3 3 because the residues are 0 , 1 , 4 {0,1,4} .

q ( 5 3 ) 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 \mod 5^3 can be written in one of these forms: a , 5 a , or 5 2 a a, 5a, \mbox{ or } 5^2a where a a is coprime to 5 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 x^2 \equiv a \mod 5^3 \\ y^2 \equiv a \mod 5^3 then x 2 y 2 0 m o d 5 3 x^2 - y^2 \equiv 0 \mod 5^3 so 5 5 divides ( x + y ) ( x y ) (x+y)(x-y) .

5 5 can't divide both of those, otherwise it would divide their sum 2 x 2x , contradicting that x 2 x^2 is coprime to 5 5 . Therefore either x y x \equiv y or x y x \equiv -y . Since we already know that a -a is a quadratic residue m o d p \mod p iff a a is, we conclude that a a is a quadratic residue m o d p n \mod p^n iff it is one m o d p \mod p .

Case 2: x 2 5 a m o d 5 3 x^2 \equiv 5a \mod 5^3 . Suppose there is s s such that 5 a s 2 m o d 5 3 5a \equiv s^2 \mod 5^3 . Since 5 s 2 5 \vert s^2 , then 5 s 5 \vert s . So 5 2 s 2 5^2 \vert s^2 , so 5 a 5 \vert a , contradicting the defintion of a a . Conclusion: 5 a 5a is never a residue.

Case 3: x 2 5 2 a m o d 5 3 x^2 \equiv 5^2a \mod 5^3 . If a a is a quadratic residue m o d 5 3 \mod 5^3 then a = s 2 a = s^2 for some s s , and then 5 2 a = ( 5 s ) 2 5^2a = (5s)^2 , so 5 2 a 5^2a is also a quadratic residue.

And if a a is not a quadratic residue m o d 5 3 \mod 5^3 then there cannot be a solution s s to 5 2 a s 2 m o d 5 3 5^2a \equiv s^2 \mod 5^3 otherwise 5 2 5^2 would divide s 2 s^2 .

Conclusion: in this case, 5 2 a 5^2a is a residue iff a a is.

Totalling the three cases and using the fact that the quadratic residues m o d 5 \mod 5 are { 0 , 1 , + 1 } \{0, -1, +1\} : Case 1 gives us all numbers of the form 5 k ± 1 m o d 5 3 5k \pm 1 \mod 5^3 , of which there are 25 2 = 50 25 * 2 = 50 . Case 3 gives us 0 , 5 2 , 5 2 0, 5^2, -5^2 which is 3 3 cases, for a sum of 50 + 3 = 53 50 + 3 = 53 .

The general rules are that the number of residues mod p p is ( p + 1 ) / 2 (p+1)/2 ; and if k < n k<n then if k k is odd, p k a p^ka is not a residue mod p n p^n ; and if k k is even, then p k a p^ka is a residue iff a a is.

Matt McNabb - 7 years, 8 months ago
Taehyung Kim
Oct 12, 2013

Let k k be the number of quadratic residues. If we have k + 1 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 k possible residues). There is a total of 159 quadratic residues so we need 160 numbers.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...