A secret spy organization uses a peculiar encryption system. Each agent has a secret ID number between 1 and 999. To authenticate, an agent must announce a number N such that when you compute N2mod1000, you get their ID number. The spy agency discovered that some ID numbers are "secure" (exactly one valid N exists between 1 and 1000) while others are "compromised" (multiple valid values of N exist). For example, ID 376 is secure because only N=624 works, but ID 0 is compromised because N∈{0,250,500,750,1000} all work. How many ID numbers between 1 and 999 are secure?
Enter a whole number
Show solution
We need to find how many values d∈{1,2,…,999} have exactly one solution to x2≡d(mod1000) in the range x∈{1,2,…,1000}.
First, note that 1000=8×125=23×53. By the Chinese Remainder Theorem, x2≡d(mod1000) if and only if both:
- x2≡d(mod8)
- x2≡d(mod125)
For any d with gcd(d,1000)=1 (i.e., d coprime to 1000), the number of solutions modulo 1000 equals the product of solutions modulo 8 and modulo 125.
The quadratic residues modulo 8 are {0,1,4}:
- d≡0(mod8): 4 solutions modulo 8
- d≡1(mod8): 2 solutions modulo 8
- d≡4(mod8): 2 solutions modulo 8
The quadratic residues modulo 125: For odd primes p, a non-zero d coprime to p has either 0 or 2 square roots modulo p. For d≡0(modp), the structure is more complex.
Key insight: If d is coprime to 1000, then modulo 8 it's either 1, 3, 5, or 7. Only d≡1(mod8) is a quadratic residue, giving 2 solutions mod 8. Similarly, if d is a quadratic residue mod 125, it has 2 solutions mod 125. By CRT, this gives 2×2=4 solutions modulo 1000.
If d is NOT coprime to 1000, the analysis becomes more intricate, but in all cases, the number of solutions is either 0 or ≥2.
The critical observation: For x2≡d(mod1000), if x is a solution, so is 1000−x (when working in residues 1 to 1000). These are distinct unless x=1000−x, which means x=500. But 5002=250000≡0(mod1000).
For any d=0: if x is a solution with 1≤x≤1000 and x2≡d(mod1000), then 1000−x is also a solution (and 1000−x=x for x=500). Thus every non-zero d has either 0 solutions or at least 2 solutions in {1,…,1000}.
Therefore, **no ID numbers between 1 and 999 are secure**.
The answer is 0.