An integer is an $n$th power if that holds true for all moduli I have not been able to solve this problem. Any insights would be appreciated!

Let $x, n > 1$ be integers. Suppose that for each $k > 1$ there exists an integer $a_{k}$
such that $x − a_k^n$ is divisible by $k$. Prove that $x = A^{n}$ for some integer $A$.

 A: Am I mistaken, or does the following (actually) elementary proof work?
To show that $x$ is a perfect $n$th power, it suffices to show that for all primes $p$, the number of times that $p$ divides into $x$ is a multiple of $n$.
To that end, fix any prime $p$, and let $r_p$ be the largest integer such that $p^{r_p}$ divides $x$. Consider $k=p^{r_p+1}$. Then, since $k$ divides $a_k^n -x$, $p^{r_p}$ divides $a_k^n$.
Moreover, it cannot be that $k = p^{r_p + 1}$ divides $a_k^n$. If it were so, then since $p^{r_p + 1}$ divides $a_k^n - x$, $p^{r_p + 1}$ would divide $x$, which contradicts the maximality of $r_p$.
Therefore, $p^{r_p}$ divides $a_k^n$ but $p^{r_p + 1}$ does not; it follows that $r_p$ is equal to the number of times $p$ divides into $a_k^n$, which must be a multiple of $n$ (consider the prime factorization of $a_k^n$), so we are done.
A: I discovered this question 6 years later. Worth emphasis: there is a much simpler proof, namely choose $\,k^{\phantom{|^{|^|}}}\!\!\!=x^2\Rightarrow\,x^2\mid x-a^n\Rightarrow\, \color{#c00}{x\mid a^n}\,$ so $\,\overbrace{ jx^2\! = x-\color{#c00}{mx}}^{\textstyle x^2\mid\, x-\color{#c00}{a^n}}\,$ for some $\,j,m\in\Bbb Z.\,$ Solving for $m\,$ we get $\,m = 1-j\:\!x,\,$ which is coprime to $\,x\,$ so, like $\,\color{#c00}{a^n}\,$ both $\color{#c00}{m\ \&\ x}^{\phantom{|^{|^|}}}\!\!\!\!\ $ must be $\,n$'th powers too.
A: This is an old chestnut: an integer which is an $n$-th power modulo
all primes is an $n$-th power.
There is a sledgehammer proof via the Chebotarev density theorem.
Suppose for the moment that $n$ is prime.
Consider $K=\mathbb{Q}(x^{1/n})$ and its Galois closure
$L=\mathbb{Q}(x^{1/n},\exp(2\pi i/n))$. Then each prime $p$ that is unramified
in $L$ splits in $K$ into various prime ideals at least one of which has norm $p$.
So its Frobenius has a fixed point on the permutation representation on the
$n$-th roots of $x$. By Chebotarev, the Galois group $G$ of $L/\mathbb{Q}$
has no element of degree $n$ and so must have a fixed point; that is one
of the $n$-th roots of $x$ must lie in $\mathbb{Q}$.
I'm sure something similar works for any positive integer $n$, but it's
too late tonight for me to work out the details :-)
A: If I am not mistaken, the question has a more elementary answer than those provided so far.  I will use the functions $\operatorname{ord}_p: \mathbb{Q}^{\times} \rightarrow \mathbb{Z}$, defined to be the largest power of $p$ appearing in the numerator minus the largest power of $p$ appearing in the denominator.  
Step 1: A positive rational number $x$ is a rational $n$th power iff for all primes $p$, $\operatorname{ord}_p(x)$ is divisible by $n$.  
This is an easy consequence of unique factorization in $\mathbb{Z}$.  
Step 2: A positive integer $x$ is an integral $n$th power iff for all primes $p$, 
$\operatorname{ord}_p(x)$ is divisible by $n$.
This follows easily from Step 1 using the fact that since $\mathbb{Z}$ is a UFD, it is integrally closed.  (Alternately, apply the rational roots theorem to the polynomial $t^n - x$.)
Step 3: As in lhf's comment above, I claim that the given condition on $x$ implies that $x$ is an nth power in $\mathbb{Q}_p$ for all primes $p$.  Indeed, taking $k$ to be a prime power, it implies that for all positive integers $a$, the congruence $t^n -x \equiv 0 \pmod{p^a}$ has a solution, and by a routine application of Hensel's Lemma, this implies that $x$ is an $n$th power in $\mathbb{Q}_p$.
Step 4: Since $x$ is an $n$th power in $\mathbb{Q}_p$, the $p$-adic valuation $v_p(x)$ is divisible by $n$.  For a rational number $x$, this means that $\operatorname{ord}_p(x)$ is divisible by $n$.  And we are done.
As regards the fancy stuff, perhaps people are thinking of the Grunwald-Wang Theorem.
This says that if $x$ is an element of a global field $K$ which is an $n$th power in all but finitely many completions at finite places $v$.  Actually, this is "Grunwald's theorem", i.e., it isn't quite true!  Wang showed that there are counterexamples to this statement, even over $\mathbb{Q}$ (if one uses all but finitely many places, rather than all places): see the wikipedia article for an explanation.  The easy proof that I give above works in any global field which is the fraction field of a PID $R$, with the conclusion that $x$ comes out to be an $n$th power up to a unit of $R$.  (When $R = \mathbb{Z}$, requiring $x$ to be positive fixes the unit ambiguity.)  
A: To be a little more concrete, here's the proof for $n = 2$.  We proceed by proving the contrapositive.  Suppose $x$ is not a square, so write $x = k^2 p_1 p_2 ... p_n$ where the $p_i$ are distinct primes, one of which may be $-1$.  By quadratic reciprocity, together with the CRT, there exists an arithmetic progression such that any prime $q$ in that arithmetic progression has the property that $\left( \frac{p_i}{q} \right) = 1$ for $1 \le i \le n-1$ and $\left( \frac{p_i}{q} \right) = -1$ for $i = n$.  A prime $q$ exists in this arithmetic progression by Dirichlet's theorem (a special case of Chebotarev's density theorem!), and $x$ is not a square $\bmod q$.  
Similarly for $n = 3$ one can give a proof using cubic reciprocity, and so on.  In general it should be possible to give a proof along these lines using Artin reciprocity, but if you're using Artin reciprocity and Dirichlet's theorem you might as well use the full strength of Chebotarev.
A: Here's an elementary proof, using the Jacobi symbol $(\frac{x}{a})$, of the fact that:
$x\in\mathbb{N}\text{ not a square }\Rightarrow\text{ for infinitely many prime numbers }p\text{, } x\text{ is not a square mod }p$
We may assume $x$ is square-free. Consider the group homomorphism $f:a\pmod {4x}\mapsto (\frac{x}{a})$ from $(\mathbb{Z}/4x)^{*}$, the group of units of $\mathbb{Z}/4x$, to $\{\pm 1\}$, where one takes a positive representative $a$ of the residue class. Using the properties of the Jacobi symbol, it is easy to see that $(\frac{x}{a})$ $=$ $(\frac{x}{a+4x})$ for $a\in\mathbb{N}$ relatively prime to $4x$, so that the definition does not depend on the particular positive representative chosen.
$f$ is not the trivial homomorphism. For if $x$ is odd, say $x=p_{1}\cdots p_{s}$ with the $p_{i}$ different primes and $s\geq1$, let $b$ be a quadratic non-residue mod $p_{1}$. Using the Chinese Remainder Theorem, take an $a\in\mathbb{N}$ such that $a\equiv b\text{ mod }p_{1}$, $a\equiv 1\text{ mod }p_{i}$ for $2\leq i\leq s$, and $a\equiv 1\text{ mod }4$. Then $(\frac{x}{a})=(\frac{a}{x})=-1$. For $x=2$ one has $f(3\text { mod }8)=-1$. And if $x=2y$ with $y=p_{1}\cdots p_{s}$ and the $p_{i}$ different odd primes as before, then one has $(\frac{x}{a})=-1$ for $a$ as above if we let $a\equiv 1\text{ mod }8$ rather than $\text{mod }4$.
The statement now follows by applying the following simple lemma to $H:=\text{ker}(f)$.
Lemma: $n\in\mathbb{N},\,H<(\mathbb{Z}/n)^{*}\text{ a proper subgroup }\Rightarrow\text{ for infinitely many primes }p\text{, } p\text{ mod }n\notin H$
Proof. Suppose $p_{1},\cdots,p_{s}$ are the only primes not dividing $n$ with residue class $\text{mod }n$ not in $H$. In case $s=0$, pick any $m\in\mathbb{N}$ relatively prime to $n$ such that $m\text{ mod }n\notin H$. And if $s\geq1$, then $p_{1}\cdots p_{s}$ and $p_{1}^{2}p_{2}\cdots p_{s}$ cannot both be in $H$ $\text{mod }n$, and we let $m$ be either of them that satisfies $m\text{ mod }n\notin H$. But $m\text{ mod }n=(m+n)\text{ mod }n$, and this is an element of $H$, because we have $q\text{ mod }n\in H$ for every prime factor $q$ of $m+n$ (as such a $q$ cannot be among the $p_{i}$). Contradiction.
I don't remember where I picked up this little gem. Its proof uses little more than the concept of a subgroup! Yet it yields many special cases of Dirichlet's theorem on primes in arithmetic progressions. It shows, for example, that there are infinitely many primes $p\equiv 2\text{ mod }3$.
A: A more elementary proof for the following:

If $x\in \mathbb{Z}$ is a square-free number not a member of $\{0,1\}$, then there exists infinitely many prime numbers such as $p$ where $(\frac{a}{p})=-1$.

Suppose the contrary. Let $p_1,\dots,p_k$ be all the odd primes where $(\frac{a}{p}) = -1$. Consider two cases:

*

*$a<0$ : Let $N$ be  $4p_1^2p_2^2\dots p_k^2(-a)-1$. There exists a prime number $q$ such that $q|N, q\overset{4}\equiv 3$. From the definition of $N$ we have $q\neq p_i, (q,a)=1$. However, $4p_1^2p_2^2\dots p_k^2(-a) \overset{q}\equiv 1 \Rightarrow (\frac{4p_1^2p_2^2\dots p_k^2 (-a)}{q})=(\frac{-a}{q})=-(\frac{a}{q})=1$ which disproves our initial assumption, proving our case.

*$a>0$: Let $a=2^\alpha m$ where $\alpha \in{0,1}$ and $m$ is an odd integer. For $m=1$ we have $a=2$, for which we have infinitely many prime numbers $p$ satisfying $p\overset{8}\equiv \pm 3$. For $m>1$, $m$ have at least one odd prime factor such as $q$. Let $\beta$ be a quadratic non-residue modulo $q$. Due to chinese remainder theorem, there exists an integer $s$ satisfying the following:
$$s\overset{8p_1p_2\dots p_k\frac{m}{q}} \equiv 1$$
$$s\overset{q} \equiv \beta$$
Then we have $(s,2ap_1\dots p_k)=1$, and using the Jacobi symbol, $$(\frac{s}{\frac{m}{q}})=1, (\frac{s}{q})=-1\Rightarrow (\frac{s}{m})=-1\Rightarrow (\frac{m}{s})*(-1)^\frac{(s-1)(m-1)}{2}=(\frac{m}{s})=-1$$
Let $s={q_1}^{\alpha_1}{q_2}^{\alpha_2}\dots{q_t}^{\alpha_t}$. Due to the initial assumption, $(\frac{a}{q_1})=(\frac{a}{q_2})=\dots=(\frac{a}{q_t})=1$. Therefore, $$(\frac{m}{s})=(\frac{2^\alpha}{s})(\frac{m}{s})=(\frac{a}{s})=(\frac{a}{q_1})^{\alpha_1}(\frac{a}{q_2})^{\alpha_2}\dots(\frac{a}{q_t})^{\alpha_t}=1\Rightarrow (\frac{m}{s})=1$$
Which is the contradiction that finalizes our proof.
