Compute $\frac 17$ in $\Bbb{Z}_3$ 
Compute $\frac 17$ in $\Bbb{Z}_3.$

We will have to solve $7x\equiv 1\pmod p,~~p=3.$

*

*We get $x\equiv 1\pmod 3.$

*Then $x\equiv 1+3a_1\pmod 9,$ so $7(1+3a_1)\equiv 1 \pmod 9$ basically lifting the exponent of $p=3,$ we get $1+3a_1\equiv 4\pmod 9\implies a_1\equiv 1\pmod 3.$

*So let $$x\equiv 1+3\cdot 1+3^2\cdot a_2 \pmod 2\implies 7(4+3^2\cdot a_2)\equiv 1\pmod {27}\implies 4+3^2\cdot a_2\equiv 4\pmod {27}\implies a_2\equiv 0 \pmod 3.$$

*So let $$ x\equiv 1+3\cdot 1+3^2\cdot 0+ 3^3\cdot a_3 \pmod {81}\implies 7(4+3^2\cdot 0+3^3\cdot a_3)\equiv 1\pmod {81}\implies 4+3^3\cdot a_3\equiv 58\pmod {81}\implies a_2\equiv 2 \pmod 3.$$

*So let $$ x\equiv 1+3\cdot 1+3^2\cdot 0+ 3^3\cdot 2+3^4\cdot a_4 \pmod {243}\implies 7(4+3^2\cdot 0+3^3\cdot 2+3^4\cdot a_4)\equiv 1\pmod {243}\implies 1+3+54+3^4\cdot a_4\equiv 139\pmod {243}\implies a_4\equiv 1 \pmod 3.$$

*So let $$ x\equiv 1+3\cdot 1+3^2\cdot 0+ 3^3\cdot 2+3^4\cdot 1+ 3^5\cdot a_5 \pmod {729}\implies 7(4+3^2\cdot 0+3^3\cdot 2+3^4\cdot 1+3^5\cdot a_5)\equiv 1\pmod {729}\implies 1+3+54+81\equiv 625\pmod {243}\implies a_5\equiv 2 \pmod 3.$$
I haven't worked out but I think $a_6$ is $0.$
So the sequence we are getting is $(a_0,a_1,a_2,a_3,a_4,\dots)=(1,1,0,2,1,2,\dots).$
But I am not sure if it's correct, since it's not being periodic. Any help?
 A: You are doing correct.
For a slightly more efficient approach, note that $7\mid 3^6-1$ by Fermat's little theorem. Then by noting that $3^6-1=7\cdot104$, we have
\begin{align*}
\frac{1}{7}
&= -\frac{104}{1 - 3^6} \\
&= -\sum_{n=0}^{\infty}104 \cdot 3^{6n} \\
&= 1 + \sum_{n=0}^{\infty} (3^{6} - 1)3^{6n} - \sum_{n=0}^{\infty}104 \cdot 3^{6n} \\
&= 1 + \sum_{n=0}^{\infty}(3^6-105)3^{6n}
\end{align*}
in $\mathbb{Z}_3$, the ring of $3$-adic integers. Then by using $3^6-105 = 212010_{(3)}$, it follows that
$$ \frac{1}{7} = \overline{212010}212011_{(3)} = \overline{021201}1_{(3)}. $$
A: lets use it 3-adic expansion here.

*

*The theorem says: A rational number with p-adic absolute value 1 has a purely periodic p-adic expansion if and only if it lies in the real interval [-1, 0). and 1/7 is periodic.

*we will use first ${-\frac{1}{7}}$ and then negate it.

*we know that  ${\overline {n_0n_1...n_{k-1}} = \frac {n_0n_1...n_{k-1}}{1-p^k}}$

*The least ${k \geq 1}$ making ${3^k \equiv 1 (mod 7)}$ is k=6. so we can take

*${3^6=729-1 =728\equiv 0 (mod7)}$, now ${728=104 \cdot 7}$ hence our equation becomes

*${-\frac{1}{7}}$=${- \frac{1\cdot104}{7\cdot104}}$ = ${- \frac{104}{3^6-1}}$ = ${-\frac{10212_3}{3^6-1}}$ = ${\frac{021201}{1-3^6}}$

*${-\frac{1}{7}=}$ ${\overline{021201...}}$, now negate to get answer, as we know

*if ${x=c_dp^d+c_{d+1}p^{d+1}+...+ c_ip^i+...  }$ here ${c_d \neq 0}$ then

*${-x = (p-c_d)p^d+ (p-1-c_{d+1})p^{d+1}+...+(p-1-c_i)p^i+...}$

*${\frac {1}{7}= {\overline {11021}}}$
