TITLE: Can one show a beginning student how to use the $p$-adics to solve a problem?
QUESTION [26 upvotes]: I recently had a discussion about how to teach $p$-adic numbers to high school students. One person mentioned that they found it difficult to get used to $p$-adics because no one told them why the $p$-adics are useful.
As a graduate student in algebraic number theory, this question is easy to answer. But I'm wondering if there's a way to answer this question to someone who only knows very basic things about number theory and the $p$-adics. I'm thinking of someone who has learned over the course of a few days what the $p$-adic numbers are, what they look like, etc, but doesn't know much more.
I'm specifically wondering if there's any elementary problem that one can solve using $p$-adic numbers. It's okay if the answer is no, and that it takes time to truly motivate them (other than more abstract motivation).

REPLY [7 votes]: A nice application is a proof of Gauss's lemma: if $f$ is a monic polynomial with integer coefficients which factors as $gh$ in $\mathbf Q[x]$, with both $g, h$ monic, then $g$ and $h$ also have integer coefficients. This involves defining the $p$-adic absolute value on polynomials as $\left|\sum a_i x^i\right|_p := \max |a_i|_p$, and then showing that $|gh|_p = |g|_p|h|_p$. Since $g$ and $h$ are monic we have $|g|_p \geq 1$ and $|h|_p \geq 1$ because $|1|_p = 1$. Since $|f|_p = 1$, we must also have $|g|_p|h|_p = 1$, so therefore $|g|_p = 1$ and $|h|_p = 1$ - that is, the coefficients of $g$ and $h$ must be $p$-integral. Since this is true for all $p$, the coefficients of $g$ and $h$ are integers. This is much cleaner than the proof using gcds/lcms of the numerators or denominators of the coefficients, and shorter than proofs that require the development of algebraic integers.
The usual proof of Gauss's lemma relies on the product of two primitive polynomials in ${\mathbf Z}[x]$ being primitive, where a polynomial $f(x)$ in $\mathbf Z[x]$ is called primitive when its coefficients have no common prime factor, or equivalently when $|f|_p = 1$ for all primes $p$. If $f$ and $g$ are primitive in $\mathbf Z[x]$ (not the same $f$ and $g$ as above!), we have $|f|_p = 1$ and $|g|_p = 1$ for all $p$, so $|fg|_p = |f|_p|g|_p = 1$ for all $p$, and therefore $fg$ is primitive! 
This is also quite a striking application of $p$-adic numbers, but it's not constructive as it involves extending the $2$-adic absolute value to the real numbers. Use at your own risk!