Find the largest 4 digit positive integer n such that 10 divides $n^{19}+99^n$ I've solved this problem and got the answer of $9991$. I manually proved how some digits could or couldn't be the ones digit of $n$, but I feel there is a faster way
 A: $n^{19}+99^n=n^{19}+(100-1)^n\equiv n^{19}+(-1)^n\bmod 10$ by Newton's formula.
We therefore need $n^{19}\equiv -1^n \bmod 10$.
Clearly both expressions cycle $\bmod 10$. So you need only solve $\bmod 10$, and the only solution is $1\bmod 10$ by inspection.
A: We first note that $\gcd(n,10)=1$ (clearly).  In particular, $n$ is odd.  Thus $99^n\equiv (-1)^n\equiv -1\pmod {10}$.
Now, $\varphi(10)=4$ so $n^{16}\equiv 1 \pmod {10}$  Thus your expression is $$n^3-1\pmod {10}$$  It is easy to see that the only cube root of $1 \pmod {10}$ is $1$ so we just want the largest $4$ digit number congruent to $1\pmod {10}$, and that's $9991$.
A: Consider this number $n$ as $XXXY$. Divisibility on $10$ of $n^{19}+99^n$ requires that last digit of it is $0$. So, what really matters here is last digits of $n^{19}$ and $99^n$.
Last digit of $99^n$ has periodic structure: $\{9,1,9,1,9,1,\dots\}\to9$ for odd $n$, $1$ for even $n$.
Last digit of $n^{19}\to XXXY^{19}\to Y^{19}$.
Together it lead to constraints:
$$
\begin{cases}
Y^{19}+9\equiv 0\mod{10},\quad \text{ if Y odd}\\
Y^{19}+1\equiv 0\mod{10},\quad \text{ if Y even}
\end{cases}
$$
where $0\le Y\le 9$.
Notice that $19$th power of even number is still even number, even $+$ odd is odd, hence second congruence has no solutions. 
Then only thing left is to examine cases $Y=\{1,3,5,7,9\}$ for $Y^{19}+9\equiv 0\mod{10}$, from where we conclude that $1$ is only suitable choice and as far as $X$ are arbitrary, we can conclude that final result should be $9991$.
