# About the sum of the first half and the latter half of the cyclic numbers of a repeating decimal

Let us call the sum of the first half and the latter half of the cyclic numbers of an irreducible fraction 'a division sum' when the period of a repeating decimal is even. Also, let $\lambda(l)$ be the length of the repeating digits of $\frac 1l$ in decimal expansion.

Example 1 : The division sum of $\frac 17$ is $142+857=999$ and $\lambda(7)=6$ because $\frac 17=0.\dot 142\ 85\dot 7$.

Then, here is my question.

Question : Is the following true?

"Suppose that $p,q$ are distinct prime numbers other than $2$ or $5$. Then, either $(1)$ or $(2)$ holds.

$(1)$ $\lambda(p)=2^h\mu, \lambda(q)=2^h\nu\ (h\ge 1, \mu,\nu$ are odd$)\Rightarrow$ the division sum of $\frac{1}{pq}$ can be represented as $99\cdots 9$.

$(2)$ $\lambda(p)=2^e\mu, \lambda(q)=2^f\nu\ (0\le e\lt f, \mu,\nu$ are odd$)\Rightarrow$ the division sum of $\frac{1}{pq}$ is in the form of repeating the cyclic number of $\frac rp$ where $r$ is the minimum natural number such that $qr\equiv 2\$(mod $p).$"

Example 2 : The division sum of $\frac 1{77}=\frac{1}{7\cdot 11}=0.\dot 012\ 98\dot 7$ is $012+987=999$. Note that $\lambda(7)=6=2^1\cdot 3,\lambda(11)=2^1\cdot 1$.

Example 3 : The division sum of $\frac 1{21}=\frac{1}{3\cdot 7}=0.\dot 047\ 61\dot 9$ is $047+619=666$. Since we know that $\lambda(3)=1=2^0\cdot 1,\lambda(7)=6=2^1\cdot 3$, $7r\equiv 2\$(mod$3)$ leads $r=2$. Note that $\frac 23=0.\dot 6$.

Example 4 : The division sum of $\frac 1{949}=\frac{1}{13\cdot 73}=0.\dot 001053740779\ 76817702845\dot 1$ is $1053740779+768177028451=769230\ 769230$. Since we know that $\lambda(13)=6=2^1\cdot 3,\lambda(73)=8=2^3\cdot 1$, $73r\equiv 2\$(mod$13)$ leads $r=10$. Note that $\frac{10}{13}=0.\dot 76923\dot 0$.

Motivation : We know that a fraction in lowest terms with a prime denominator other than $2$ or $5$ (i.e. coprime to $10$) always produces a repeating decimal. We can prove that the division sum of $\frac 1p$ can be represented as $99\cdots 9$ when $p$ is a prime other than $2$ or $5$. I've been thinking about its generalization. Then, I reached the above expectation. This expectation seems true, but I can't prove it. Can anyone help?

By the way, if my expectation is true, the following follows.

"Suppose that $p\ge 7$ is a prime number and that the period of the repeating decimal $\frac{1}{3p}$ is even. If $p\equiv 1\ ($mod $3)$, then the division sum of $\frac{1}{3p}$ can be represented as $66\cdots 6$. If $p\equiv 2\ ($mod $3)$, then the division sum of $\frac{1}{3p}$ can be represented as $33\cdots 3.$"

Update : I crossposted to MO.

If $n$ is coprime with $10$, then $\lambda(n)$ is the order of the class of $10$ in $(\Bbb Z/n \Bbb Z)^*$.

If $\lambda(n) = 2k$, then $10^k$ is a nontrivial square root of $1$ mod $n$ (there may be several of them), and if $a,b$ are the first and second half of the repeating pattern of $\frac 1n$, then :

$0 \le a,b \lt 10^k$ ; $a \neq b$ ; $10^ka+b = (10^{2k}-1)\frac 1n > 0$.
From this equality we get $a+b = (10^k-1)((10^k+1)\frac 1n - a)$.
Also, since $a = \lfloor 10^k \frac 1n \rfloor$, we get $a+b \le (10^k-1)(1+ \frac 1n)$

If $10^k = -1 \pmod n$, then $a+b$ is a positive multiple of $10^k-1$, so it must be $10^k-1$.

Suppose $n=pq$. By the chinese remainder theorem, $\lambda(n) = lcm(\lambda(p),\lambda(q))$.
If both $\lambda(p)$ and $\lambda(q)$ are even, say $\lambda(p)=2k_p, \lambda(q)=2k_q$, then $k = lcm(k_p,k_q)$.

Then, $10^k \equiv -1 \pmod n \iff 10^k \equiv -1 \pmod {p,q} \iff k$ is an odd multiple of $k_p$ and $k_q$. And this happen if and only if the exposant of $2$ in the prime factorisation of $k_p$ and $k_q$ are equal. So we have done your case $(1)$.

If we are not in case $(1)$ (and $\lambda(pq)$ is even), then we are in case $(2)$ : $\lambda(p)=2^e\mu, \lambda(q) = 2^f \nu$, with $e \neq f$ (we can assume $e<f$ by switching $p$ with $q$ if it's not the case). We then have $\lambda(pq) = 2^f lcm(\mu,\nu)$, so $k$ is an odd multiple of $k_q$ and a multiple of $\lambda(p)$. Hence $10^k \equiv 1 \pmod p$ and $10^k \equiv -1 \pmod q$. Looking back at our formula for $a+b$, $(10^k+1)\frac 1n$ simplifies into $u/p$ for some integer $u$. And so, $a+b = (10^k-1)\frac rp$ for some positive integer $r$. From our upper bound on $a+b$, we have $r \le p(1+ \frac 1n) = p + \frac 1q$, hence $1 \le r \le p$.

So to determine $r$ it is enough to determine it modulo $p$. We know that modulo $p$, $r \equiv u = (10^k+1)/q \equiv 2/q$, hence $qr \equiv 2 \pmod p$, which is what you wanted.