# recurring decimal

I would like to know solution of the following one, which I had in my mind from many weeks. Given $p$ with $(10, p) = 1$, the digits $a_k$ in the recurring decimal expansion of $1/p$: This can be written as $1/P = 0.a_1 a_2 \ldots a_N$ (this value is repeatedly repeating) are obtained as follows.

1) Determine the least positive residues $r_k$ of $10^k \pmod p$: $10^k\equiv r_k \pmod p$ for $0 \leq r_k <p$.

2) Take $T = 1$ for $p\equiv 9 \pmod {10}$, $T = 3$ for $p \equiv 3 \pmod {10}$, $T = 7$ for $p\equiv 7 \pmod {10}$ and $T = 9$ for $p \equiv 1 \pmod {10}$.

Thus in all cases $pT\equiv 9 \pmod {10}$ or $pT \equiv -1 \pmod {10}$, Then $Tr_k\equiv a_k \pmod {10}$ for $0\leq a_k\leq 9$. I.e., $a_k$ are the last digits of $Tr_k$. “I would like to participate in a discussion on this problem(s)”

Edit: attempt at a clarification by user7530:

Let $p$ be an integer with $(10,p)=1$. Then $1/p$ is a periodic decimal $$1/p = 0.a_1 a_2 \ldots a_N a_1 a_2 \ldots$$ with period $N$.

I've observed that the digits $a_k$ satisfy the congruence $$a_k \equiv -p^{-1} (10^k \bmod p) \mod 10.$$

Is this formula correct? Is there a proof?

-
You say "Given P with $(10,p)=1$". You used a capital $P$, then a lower-case $p$. Did you intend those to be understood as being the same number? If so, you should be consistent. It's standard to use those in mathematical notation as two different things that can refer to different numbers. –  Michael Hardy Nov 18 '11 at 19:12
sorry! both are same sir –  krrg Nov 18 '11 at 19:24
"generalize/discuss this" has a long track record of getting closed. –  anon Nov 18 '11 at 21:45
Straight from the FAQ: If your motivation for asking the question is “I would like to participate in a discussion about ______”, then you should not be asking here. –  Brandon Carter Nov 18 '11 at 22:48
There is a grain of a good question here. I'll make an attempt at editing the original post. –  user7530 Nov 19 '11 at 8:56

I'm not sure I understand the question, but I note that $10^k/p=a_1a_2\dots a_k.a_{k+1}a_{k+2}\dots$ and if you truncate to an integer and look at that integer modulo 10 you get $a_k$.
@krrg Is there something in particular you're confused about? I tried to keep the question exactly the same, but improve the notation/exposition a bit. $(10^k \bmod p)$ is your $r_k$, and $p^{-1}$ the multiplicative inverse of $p$ in $\mathbb{Z}/10\mathbb{Z}$ (your $-T$). –  user7530 Nov 19 '11 at 21:00
Ah! I see it now... your answer implies that $\frac{10^k - (10^k\bmod p)}{p}$ is an integer and is congruent to $a_k$ mod 10, from which follows krrg's formula. –  user7530 Nov 20 '11 at 8:41