For example, I have 0.786786786... How do I find the fraction equivalent?
3 Answers
Let $x=0.7\color{red} {86}786\overline{786}$ where I fixed what I believe is a typo. Then $1000x=768.768786\overline{786}$ or $999x=786$ If there are $n$ digits in the repeat, you multiply by $10^n$.
General method:
- Let $x$ denote the input number
- Let $|n|$ denote the number of decimal digits in $n$
- Split $x$ into the following parts:
- $\color\red{A}=$ the integer part, i.e., $\lfloor{x}\rfloor$
- $\color\green{B}=$ the fraction part's non-periodic prefix
- $\color\orange{C}=$ the fraction part's periodic postfix
Then:
$$x=\frac{(10^{|B|+|C|}-10^{|B|})\color\red{A}+(10^{|C|}-1)\color\green{B}+\color\orange{C}}{10^{|B|+|C|}-10^{|B|}}$$
For example, if $x=0.768\overline{786}$:
- $\color\red{A}=0$
- $\color\green{B}=768$
- $\color\orange{C}=786$
Then:
$$x=\frac{(10^{3+3}-10^{3})\color\red{0}+(10^{3}-1)\color\green{768}+\color\orange{786}}{10^{3+3}-10^{3}}=\frac{768018}{999000}$$
$.768\overline{786}=\frac{786}{999}-(.786-.768)=\frac{786}{999}-\frac{18}{1000}=\frac{128003}{166500}$