# An integer with same remainder modulo $p$ and $p^2$ (corrected)

Let $p\in \mathbb{Z}_{\geq 1}$ be a prime number, and consider the ring $\mathbb{Z}_{p}$ of $p$-adic integers. Now every rational number $n \in \mathbb{Q}$ is a $p$-adic integer for all but finitely many primes $p$, so for any given $n \in \mathbb{Q}$ let us ignore the finitely many primes where this is not the case.

Every $n \in \mathbb{Z}_{p}$ has a unique expression of the form $$a_0+a_1p+a_2p^2+\dots$$ where $0 \leq a_i \leq p-1$ for every $i\geq 0$.

Now for any given $n \in \mathbb{Q}$ there are only finitely many primes $p$ such that $n \in \mathbb{Z}_{p}$ and $a_0=0$. In other words, $n$ is a unit element in $\mathbb{Z}_{p}$ for almost all prime $p$.

My question is: can we say the same about the other coefficients $a_1,a_2,\dots$? For a given $n \in \mathbb{Q}$, is $a_1=0$ for only finitely many primes $p$?

$***************************************************$

As for context, this problem is a toy instance of a subproblem that arose as part of my attempt at this question I had asked earlier: When can an algebraic number be approximated by a $p$-adic number? Evidently, that question is not juicy enough to attract eyeballs, and requires more background. However, this simpler formulation captures the core of that problem (I think). I apologize if the solution turns out to be trivial, but clearly I am missing the picture.

UPDATE: As was pointed out in the comments (sorry and thanks!), I had worded the question wrong earlier. I think I have rectified it now, but if its still silly, I'll edit it again.

• Actually, it's true for infinitely many primes for any $n$, because for infinitely many primes, $p>n$ so $n\bmod p = n\bmod {p^2}=n$. Dec 6, 2016 at 20:44
• This holds for every integer. Dec 6, 2016 at 20:45
• Doesn't every integer $n$ have an infinite set of primes such that $n\pmod{p_i^2} =n\pmod{p_i}$, namely, the set of all primes greater than $n$? Did you mean to ask a different question? Dec 6, 2016 at 20:48
• Oh! You're right! This isn't what I had in mind then. I'll remove this question and reword it better. Meanwhile, do check out the original question linked above. Dec 6, 2016 at 21:05
• @ThomasAndrews , Mark Fischler and mixedmath: Thanks for pointing it out. I had considered that earlier, but somehow forgot about it when typing down the question. I have corrected it now, and hopefully my essential problem is conveyed. Do tell me if there's more to fix. Thanks. Dec 6, 2016 at 21:31

This is true for all positive integers $n$: For any $p > n$ we have $n \pmod{p^2} = n \pmod p = n$.
On the other hand, if $p \le n < p^2$ then $n \pmod{p^2} \ne n \pmod p$, so no integers $> 1$ will have $n \pmod{p^2} = n \pmod{p}$ for all primes $p$.
EDIT: For the revised (and completely different) question, if $n$ is a nonnegative integer and $p$ is a prime $> n$, then the $p$-adic expansion of $n$ has $a_0 = n$, $a_j = 0$ for $j \ge 1$. But these are the only examples.
If $n$ is a negative integer and $p > -n$, the $p$-adic expansion of $n$ is $(p+n) + (p-1) p + (p-1) p^2 + \ldots$, so $a_1 \ne 0$.
Finally, suppose $n = c/d$ (in lowest terms) is not an integer. Let $p$ be a prime $> 2 \max(c,d)$. In order for the $p$-adic expansion to be $\dfrac{c}{d} = a_0 + 0 p + \ldots$, we need $p^2 \mid c - a_0 d$. But $0 < a_0 < p$, and $|c - a_0 d| < p/2 + p^2/2 < p^2$, so this implies $c - a_0 d = 0$, contradicting our assumption $c/d$ is not an integer. So there can be only finitely many $p$ for which $a_1 = 0$.