Let $A$ be an acute angle such that $\tan A = 2 \cos A.$ Find the number of positive integers $n$ less than or equal to $1000$ such that $\sec^n A + \tan^n A$ is a positive integer whose units digit is $9.$
Denote $a_n = \sec^n A + \tan^n A$.
For any $k$, we have
\begin{align*} a_n & = \sec^n A + \tan^n A \\ & = \left( \sec^{n-k} A + \tan^{n-k} A \right) \left( \sec^k A + \tan^k A \right) - \sec^{n-k} A \tan^k A - \tan^{n-k} A \sec^k A \\ & = a_{n-k} a_k - 2^k \sec^{n-k} A \cos^k A - 2^k \tan^{n-k} A \cot^k A \\ & = a_{n-k} a_k - 2^k a_{n-2k} . \end{align*}
Next, we compute the first several terms of $a_n$.
By solving equation $\tan A = 2 \cos A$, we get $\cos A = \frac{\sqrt{2 \sqrt{17} - 2}}{4}$.
Thus, $a_0 = 2$, $a_1 = \sqrt{\sqrt{17} + 4}$, $a_2 = \sqrt{17}$, $a_3 = \sqrt{\sqrt{17} + 4} \left( \sqrt{17} - 2 \right)$, $a_4 = 9$.
In the rest of analysis, we set $k = 4$.
Thus,
\begin{align*} a_n & = a_{n-4} a_4 - 2^4 a_{n-8}  \\ & = 9 a_{n-4} - 16 a_{n-8} . \end{align*}
Thus, to get $a_n$ an integer, we have $4 | n$.
In the rest of analysis, we only consider such $n$. Denote $n = 4 m$ and $b_m = a_{4n}$.
Thus,
\begin{align*} b_m & = 9 b_{m-1} - 16 b_{m-2} \end{align*}
with initial conditions $b_0 = 2$, $b_1 = 9$.
To get the units digit of $b_m$ to be 9, we have
\begin{align*} b_m \equiv -1 & \pmod{2} \\ b_m \equiv -1 & \pmod{5} \end{align*}
Modulo 2, for $m \geq 2$, we have
\begin{align*} b_m & \equiv 9 b_{m-1} - 16 b_{m-2} \\ & \equiv b_{m-1} . \end{align*}
Because $b_1 \equiv -1 \pmod{2}$, we always have $b_m \equiv -1 \pmod{2}$ for all $m \geq 2$.
Modulo 5, for $m \geq 5$, we have
\begin{align*} b_m & \equiv 9 b_{m-1} - 16 b_{m-2} \\ & \equiv - b_{m-1} - b_{m-2} . \end{align*}
We have $b_0 \equiv 2 \pmod{5}$, $b_1 \equiv -1 \pmod{5}$,
$b_2 \equiv -1 \pmod{5}$, $b_3 \equiv 2 \pmod{5}$, $b_4 \equiv -1 \pmod{5}$, $b_5 \equiv -1 \pmod{5}$, $b_6 \equiv 2 \pmod{5}$.
Therefore, the congruent values modulo 5 is cyclic with period 3.
To get $b_m \equiv -1 \pmod{5}$, we have $3 \nmid m \pmod{3}$.
From the above analysis with modulus 2 and modulus 5, we require $3 \nmid m \pmod{3}$.
For $n \leq 1000$, because $n = 4m$, we only need to count feasible $m$ with $m \leq 250$.
The number of feasible $m$ is
\begin{align*} 250 - \left\lfloor \frac{250}{3} \right\rfloor & = 250 - 83 \\ & = \boxed{\textbf{(167) }} . \end{align*}
~Steven Chen (Professor Chen Education Palace, www.professorchenedu.com)