Is a decimal with a predictable pattern a rational number?

Solution 1:

A number is rational if and only if it has an eventually repeating decimal representation. So a number like

$$4.212121...$$

or $$4.999212121...$$

is rational, while the number

$$4.212112111211112...$$

is not.

Solution 2:

A real number is rational if and only if its decimal expansion terminates or eventually repeats.


Lemma: Every prime $p \neq 2, 5$ divides a repunit.

Proof of Lemma:

Fix a prime $p \neq 2,5$. Let $\textbf{A}$ be the set of repunits, so

$$\textbf{A} = \left\{\displaystyle\sum\limits_{k=1}^{n} 10^{k-1} \, \mid \, n \in \mathbb{N} \right\} = \left\{\frac{10^n -1}{9} \, \mid \, n \in \mathbb{N} \right\}$$

Consider the repunits, modulo $p$. Since $\mathbb{N}$ is not a finite set, neither is $\textbf{A}$. There are a finite number of remainders modulo $p$ (specifically, $p$ possible remainders).

There are (infinitely) more repunits than remainders modulo $p$. Thus, there must exist two distinct repunits with the same residue modulo $p$. So $$ \exists \, a, b \in \textbf{A} \,\, \text{s.t.} \,\,\,\,\,\, a \equiv b \pmod{p}, \,\, a \neq b$$

Without loss of generality, assume $a > b$.

Since $a, b \in \textbf{A}$, $\exists \, x, y \in \mathbb{N}$ with $x > y$ such that

$$a = \frac{10^x - 1}{9}$$

$$b = \frac{10^y - 1}{9}$$

We can substitute in to $a \equiv b \pmod{p}$ to get:

$$\frac{10^x - 1}{9} \equiv \frac{10^y - 1}{9} \pmod{p}$$

$$\frac{\left(10^x - 1\right)-\left( 10^y - 1\right)}{9}\equiv 0 \pmod{p}$$

$$\frac{10^x-10^y}{9} \equiv 0 \pmod{p}$$

$$\frac{\left(10^y\right)\left(10^{x-y}-1 \right)}{9}\equiv 0 \pmod{p}$$

We know that $p \nmid 10^y$, because $p$ is not $2$ or $5$. Since $\mathbb{Z}/p\,\mathbb{Z}$, the ring of integers modulo $p$, has no zero divisors (because $p$ is prime),

$$\frac{10^{x-y}-1}{9}\equiv 0 \pmod{p}$$

This is a repunit.


Since our choice of $p \neq 2, 5$ was arbitrary, we have proved that every prime that is not $2$ or $5$ divides a repunit. It follows that every prime that is not $2$ or $5$ divides nine times a repunit (a positive integer whose digits are all nines).

Note that this proof applies to any value of $p$ (not necessarily prime) so that $p$ is not divisible by $2$ or $5$. The step involving the absence of zero divisors in $\mathbb{Z}/p\,\mathbb{Z}$ can be modified to state that $\gcd\left(10^y, p\right) = 1$ when $2 \nmid p$ and $5 \nmid p$.


Every rational number has a decimal representation that either terminates or eventually repeats.

Proof:

Consider a positive rational number $N = r/s$ for $r, s \in \mathbb{N}$ with $\gcd(r,s) = 1$.

If $s=1$, $N$ trivially has a terminating decimal expansion. Suppose $s \neq 1$.

Let $m_i$ be positive integers and $q_i \in \mathbb{N}$ be $n$ primes with $q_k < q_{k+1}$ so that

$$s = q_{1}^{m_1} \cdot q_{2}^{m_2} \cdots q_{n}^{m_n} = \displaystyle\prod\limits_{k=1}^{n} q_{k}^{m_k}$$

We'll do casework on the prime factorization of $s$, the denominator of $N$.

  • Case $1$: The $q_i$ consist only of a $2$ and/or a $5$.

In this case, the decimal expansion of $r/s$ terminates because $N$ can be written as $M/\left(10^z\right)$ for some $M, z \in \mathbb{N}$.

  • Case $2$: $q_i \neq 2, 5$ for all $i \in \mathbb{N}, \, 1 \leq i \leq n$

As noted above (below the proof of the lemma), every natural number that is not divisible by $2$ or $5$ divides nine times a repunit. Thus, in this case, $s$ divides nine times a repunit. There exist $x_0, y_0 \in \mathbb{N}$ such that $$x_0 \cdot s = 10^{y_0}-1$$

$$ s = \frac{10^{y_0}-1}{x_0}$$

Now we can rewrite $N$:

$$N = \frac{r}{s} = \frac{r \cdot x_0}{10^{y_0}-1}$$

Since $r \cdot x_0 \in \mathbb{N}$, this is a positive integer divided by nine times a repunit. We know that this gives a repeating decimal, with a period that divides $y_0$.

  • Case $3$: The $q_i$ consist of a mix of primes equal to $2$ or $5$, and other primes.

In this case $N$ can be written as the product of two rational numbers, call them $N_1$ and $N_2$, that fit cases $1$ and $2$, respectively. Then there exist, $M, z, r, x_0, y_0 \in \mathbb{N}$ such that $$ N = N_1 \cdot N_2 = \frac{M}{10^z} \cdot \frac{x_0 \cdot r}{10^{y_0}-1}$$

$$ N = \frac{1}{10^z} \cdot \frac{M \cdot x_0 \cdot r}{10^{y_0} -1}$$

The factor of $1/\left(10^z\right)$ only shifts the decimal representation by $z$ places. The other factor must be a repeating decimal with a period that divides $y_0$. Thus, the decimal expansion of $N$ eventually repeats.

Thus, every rational number has a decimal representation that either terminates or eventually repeats.


The contrapositive of the statement we just proved shows that the number you encountered is irrational. If a real number does not have a terminating or eventually repeating decimal expansion, then it is not rational.

Note that the converse is also true: every decimal number that either terminates or eventually repeats is a rational number. This is easier to prove.

The number you encountered was not rational, not a terminating decimal, nor an eventually repeating decimal.

Well-known examples of other real numbers that have predictable patterns but are not rational include Champernowne's number and Liouville's constant.

Solution 3:

The number 4.212112111211112... is not a rational number , since the pattern is non-terminating and will never repeat .

You can not write this as a ratio of rational number .