I was playing around with quadratic residues in $3^n$ modulo systems and am now wondering if there is a neat closed form solution for the set of all quadratic residues in $\mathbb{Z}/3^n \mathbb{Z} $ for any n.
A couple minutes of fiddling and it's easy to prove that all numbers of the form 3x+1 are residues.
However, I'm not seeing anything immediately in the remaining residues congruent to 0 mod 3.
Haven't found anything on this particularly simple case anyway on the internet.
Every other power of 3 is congruent to 1 mod 8, so perhaps there's not a good solution...?
The group has two components, one which is the number of powers of $3$ that are in your number, and one that is the unital translate thereof, because all (non-zero) integers have a unique representation of the form $3^j\cdot m$ with $\gcd(m,3)=1$, and so
$$\Bbb Z/3^n\Bbb Z\cong RU$$
with
$$\begin{cases}R=\{ 3^k:0\le k\le n\}\\ U=(\Bbb Z/3^n\Bbb Z)^\times\end{cases}$$
this is not a group product, as the group operation is addition, but is a representation via products of numbers (which is sufficient for talking about residues). So first you ask if the power of $3$ involved is even or $n$, if not: no dice, if so proceed to step 2. Step 2: is the unital component a square in $(\Bbb Z/3^n\Bbb Z)^\times$? If so: yes, if so and $3^n\not\equiv 0$, then no.
We can even deal with the units explicitly: $(\Bbb Z/3^n\Bbb Z)^\times$ is a cyclic group, and so you need the unique subgroup of index $2$ of squares within it. However, everything projects down to either $1$ or $-1\mod 3$ in this group, so and this is a homomorphism from $U\to\{\pm 1\}=(\Bbb Z/3\Bbb Z)^\times$, which is non-trivial, hence its kernel, namely everything which is $1\mod 3$ is exactly equal the group of unital squares.
So we know that all squares modulo $3^n$ are numbers of the form
$$\begin{cases}m=3^{2k}(3k+1) & 0\le 2k\le n\\ m & 3^n|m\end{cases}.$$