The fraction $\frac{1}{p}$, where $p$ is a prime number coprime with 10, is presented as an infinite periodic fraction. Prove that, if the number of digits in the period is even, then the arithmetic mean of the digits in the period is equal to $\frac{9}{2}$.
Let $\mathbb{P}$ be the set of natural prime numbers.
The length of the smallest non-repeating block in decimal representation of $\frac{1}{p}$ , where $p \in \mathbb{P} \setminus \{ 2,3,5\} $ is always even.
Proof :
Let $p$ be a prime and $ p\not=2,3,5$ let
$$ \frac{1}{p} = 0.\overline{ a_{k-1}a_{k-2}\dots a_1a_0 } $$where $a_i \in \{0,1,2,\dots,9\} \ \forall \ 0 \leq i \leq n $
So the length of the smallest non-repeating block in decimal representation of $\frac{1}{p}$ is $k$.
$$ \therefore \frac{10^k - 1}{p} = a_{k-1}a_{k-2}\dots a_1a_0 \in \mathbb{Z} $$$\Rightarrow k$ is the minimum positive integer such that $ p | 10^k - 1 $
Thus $ k = ord_p(10) | p-1 \Rightarrow k $ is even ( as $k \not= 1, \ \because p \not= 3$ )
Let $N = ( b_t b_{t-1} \dots b_1b_0 )_{10}$ then for all positive integer $ v > t $ we have $ S(Nx) = 9v $ where $ x = 10^v - 1 $
Proof :
$$ Nx = ( b_t b_{t-1} \dots b_1 b_0 )_{10} \left( \underbrace{ 99\dots 99 }_{ v \mbox{ times } 9 } \right) $$Assume that $b_0 \not= 0$ because if $b_0 = 0$ we can simply look at $\frac{Nx}{10} $
Now consider the number $$ \alpha = \left( b_t b_{t-1} \dots b_1 ( b_0 - 1) \underbrace{99\dots99}_{ v-t-1 \mbox{ times } 9 }(9-b_t)(9-b_{t-1}) \dots (9-b_1)(9-b_0 +1 ) \right)_{10} $$We will prove that $ \alpha = Nx $
$$ \alpha = \left( b_t \dots b_1( b_0-1) \right)_{10} \cdot 10^v + \left( \underbrace{99\dots99}_{v-t-1 \mbox{ times } 9 } \right) \cdot 10^{t+1} + \left( (9-b_t)(9-b_{t-1})\dots(9-b_1)(9-b_0+1) \right)_{10} $$$$ \Rightarrow \alpha = N \cdot 10^v - 10^v + \left( 10^{v-t-1} -1 \right) \cdot 10^{t+1} + 9 \left( \sum_{i=0}^{t} 10^i \right) - N + 1 $$$$ \Rightarrow \alpha = N \cdot 10^v - 10^v + (10^v - 10^{t+1}) + (10^{t+1} -1) - N+1 = N( 10^v-1) = Nx $$$$ \therefore S(Nx) = S(\alpha) = \left(\sum_{i=0}^t b_i \right) -1 + 9( v-t-1) -\left( \sum_{i=0}^t ( 9 - b_i ) \right) + 1= 9v $$
Now coming to the main proof, let $ n = a_{k-1}a_{k-2} \dots a_1a_0 = \frac{10^k - 1}{p} $
So we need to proof that $ \frac{ S(n) }{k} = \frac{9}{2} $ where $S(x) \equiv $ sum of digits of the decimal representation of positive integer $x$
Let $k = 2m $ where $m \in \mathbb{N} $
$$ \Leftrightarrow S\left( \frac{10^{2m} - 1}{p} \right) = \frac{9k}{2} $$$$ \Leftrightarrow S\left( \frac{(10^m-1)(10^m + 1) }{p} \right) = 9m $$Now set $ N = \frac{10^m + 1}{p} \in \mathbb{N} $ and $x= 10^m - 1$ Clearly $ \lfloor \log_{10} N \rfloor + 1 \leq m $, so our lemma holds and thus
$$ S \left( \left(\frac{10^m+1}{p}\right) ( 10^m - 1 ) \right) = 9m $$$\Rightarrow S(n) = 9m = \frac{9k}{2}$
$$ \boxed{ \therefore \frac{ S(n) }{k} = \frac{9}{2} }$$Hence proved.