Question
Question: How many natural numbers n ≤ 105 are there such that 7 exactly divides $2^n - n^2$...
How many natural numbers n ≤ 105 are there such that 7 exactly divides 2n−n2

30
Solution
We need to find the number of natural numbers n≤105 such that 2n−n2≡0(mod7), or 2n≡n2(mod7).
-
Powers of 2 modulo 7: 21≡2, 22≡4, 23≡1(mod7). The cycle length is 3.
- n≡0(mod3)⟹2n≡1(mod7)
- n≡1(mod3)⟹2n≡2(mod7)
- n≡2(mod3)⟹2n≡4(mod7)
-
Squares modulo 7:
- n≡0(mod7)⟹n2≡0(mod7)
- n≡1,6(mod7)⟹n2≡1(mod7)
- n≡2,5(mod7)⟹n2≡4(mod7)
- n≡3,4(mod7)⟹n2≡2(mod7)
-
Combining conditions using CRT (modulo 21):
- If n≡0(mod3) (2n≡1), we need n2≡1(mod7), so n≡1,6(mod7).
- n≡0(mod3),n≡1(mod7)⟹n≡15(mod21).
- n≡0(mod3),n≡6(mod7)⟹n≡6(mod21).
- If n≡1(mod3) (2n≡2), we need n2≡2(mod7), so n≡3,4(mod7).
- n≡1(mod3),n≡3(mod7)⟹n≡10(mod21).
- n≡1(mod3),n≡4(mod7)⟹n≡4(mod21).
- If n≡2(mod3) (2n≡4), we need n2≡4(mod7), so n≡2,5(mod7).
- n≡2(mod3),n≡2(mod7)⟹n≡2(mod21).
- n≡2(mod3),n≡5(mod7)⟹n≡5(mod21).
The possible residues modulo 21 are {2,4,5,6,10,15}. There are 6 such residues.
- If n≡0(mod3) (2n≡1), we need n2≡1(mod7), so n≡1,6(mod7).
-
Counting numbers up to 105: Numbers are of the form n=21k+r, where r∈{2,4,5,6,10,15}. We need 1≤21k+r≤105. For each of the 6 residues, k can range from 0 up to ⌊21105−r⌋. For r=2, k≤⌊21103⌋=4. k∈{0,1,2,3,4} (5 values). For r=4, k≤⌊21101⌋=4. k∈{0,1,2,3,4} (5 values). ... For r=15, k≤⌊2190⌋=4. k∈{0,1,2,3,4} (5 values). Since 105=5×21, each residue class has exactly 5 numbers in the range [1, 105]. Total count = 6 residues×5 numbers/residue=30.
