[Math] the probability of randomly choosing a rational number from $[0,1]$

borel-cantelli-lemmasprobabilityprobability theory

Im doing a (beautiful) guided excercise to calculate the probability of randomly choosing a rational number from the interval $[0,1]$. So im working with the decimal expansion of this randomly chosen number $X \in [0,1]$.

My question is: Is there an "if only if" of the type

$X\in [0,1]$ is rational if only if its decimal expansion is of the form…

I've searched in Wiki, and found that if $X\in [0,1]$ is a rational number, then its decimal expansion is either finite, or some part of the expansion is indefinetly repeated. However, this doesn't necessairily mean that if I get a number with a decimal expansion with some sort of repetition, then this number is rational. Can someone clear this out for me?

Best Answer

This is a neat proof: suppose I have a number (between 0 and 1, say) whose decimal expansion eventually repeats: $$x=a_1. . . a_nb_1. . . b_mb_1. . . b_mb_1. . . b_m . . .$$ where $a_i, b_i$ are decimal digits. (This includes the case when the decimal expansion terminates: then we just have $m=1, b_1=0$.)

Then we have$^*$

$$10^nx-a_1a_2. . . a_n=0.b_1. . . b_mb_1 . . . b_m . . .$$ Let $y=10^nx-a_1a_2. . . a_n$. Then we have $$10^my-b_1. . . b_m=y,$$ so $$y={b_1. . . b_m\over 10^m-1},$$ so $y$ is rational; and $$x={y+a_1. . .a_n\over 10^n},$$ so $x$ is rational.


$^*$ Note that I'm writing "$a_1 . . . a_n$" for the number whose first digit is $a_1$, etc. - not exactly standard notation, but clear in this context.

Related Question