The value of the geometric series within the parentheses is 1/(1-10^{-k}).
Therefore

0.K = (K/10^{k})(1/(1-10^{-k}) = K/(10^{k}−1)

Thus any repeating decimal is a rational number.
The form K/(10^{k}−1) may not give the rational number in its simplest form.
For example, for K=142857 both 142857 and 999999 are divisible by 142857 so 0.142857=1/7.

Let p and q be such that

K/(10^{k}−1) = p/q

where p is less than q.

Then

K = p(10^{k}−1)/q

Now consider which values of K are such that p=1. This requires that q be a factor of (10^{k}-1).
Take the case of k=6. The number 999,999 has a prime factorization of 3³7·11·13·37.
Thus 1/3, 1/7, 1/11, 1/13 and 1/37 have such a repeating form. Note that 1/3=0..33333333… can
be considered as a repeition of 333333 as well as a repetition of 3. But also 1/9, 1/21, 1/33, 1/39, 1/111 and
so on will have that form, but likewise with 1/27, 1/45 and so forth.

Any multiple of (10^{k}−1)/q for such values of q generated as a product of the
prime factors of (10^{k}−1) will be a repeating decimal such as

2/3 = 0.666666
2/7 = 0.285714

These multiples can only go up to (q-1).

The Relevant Factors

Note that (10^{k}−1) always has 9 as a factor.
Therefore the crucial numbers for factorization are 111…111. The table below shows the
factorization of integers to the base 10 which are sequences of 1.

Number

Factorization

1

1

11

11

111

3·37

1111

11·101

11111

41·271

111111

3·7·11·13·37

1111111

239·4649

11111111

11·73·101·137

For proof that the decimal representation of any rational number must terminate in
a repeating decimal see Decimal Representation of Rationals