I want to know about combinatorial way to solve this problem.
The problem is
How many natural number $n<1000$ that are satisfied
$(2^n- n^2)\pmod 7=0$.
I solved like remainders that $2^n$ divided by 7 are have 3-cycles and those of remainders that $n^2$ devided by 7 have 7-cycles. So $n$ has 21-cycle and so on. But someone said there are combinatorial way to solve this and I want to know but I've got no idea.
Since you observe that $2^n \bmod 7$ gives a 3-cycle, you can consider just three cases corresponding to the different residues$\bmod 3$.
For $n\equiv 0 \bmod 3$ you have $2^n\equiv 1 \bmod 7$ thus $n^2\equiv 1 \bmod 7$. Then $n\in\{1,6\}\bmod 7$ and you use the Chinese Remainder Theorem to render $n\in\{15,6\}\bmod 21$ (same order as the $\bmod 7$ resudues).
For each of $n\equiv 1\bmod 3$ and $n\equiv 2\bmod 3$ you get two more residues $\bmod 21$ and then you form the union of the results from the three cases.