= Repdigit
{title2=$R_n=d\frac{b^n-1}{b-1}$}
{wiki}
A <repdigit> is a positive integer whose base-$b$ expansion repeats one nonzero digit $d$. For $b\ge2$, $1\le d<b$ and $n\ge1$, the <finite geometric series> gives $R_n=d(1+b+\cdots+b^{n-1})=d(b^n-1)/(b-1)$. For example, $5(10^n-1)/9$ has $n$ decimal digits, all equal to five.
Every <prime number> not dividing $b$ divides infinitely many such <repdigits>. If it divides $d$, every length works. Otherwise, if it does not divide $b-1$, the <Fermat little theorem> gives divisibility for lengths that are multiples of $p-1$, and division by $b-1$ is justified by its <modular inverse>. If $p\mid b-1$, the sum is congruent to $dn$ modulo $p$, so lengths divisible by $p$ work instead. A prime dividing $b$ but not $d$ divides none, since $R_n\equiv d\pmod p$. This distinction prevents invalid cancellation of the geometric-sum denominator.
Back to article page