Consider the rational number which in decimal form is .12345345345345...
It begins with two nonrepeating digits followed by a block of 3 digits which repeats.
For the generalized repeating decimal
.[a][b][b][b][b]...
Where [a] has n digits and [b] has m digits.
Find a general way to transform it into a rational number of the form p/r.
Take it in two parts:
.[a] is a/10^n
.[b][b][b][b]... would be b/(10^m  1), but we have this divided by 10^n.
So the total value is a / 10^n + b / ((10^m  1)*(10^n))
A common denominator is ((10^m  1)*(10^n)), so we get
(a * (10^m  1) + b) / ((10^m  1)*(10^n))
In the specific example of .12345345345345..., a = 12, n = 2, b = 345, m = 3, and we get
(12 * (10^3  1) + 345) / ((10^3  1)*(10^2)) or
(12*999 + 345) / 99900 = 12333/99900
The numerator and denominator have a gcd of 3, so this reduces to 4111/33300.
Note that 10^m  1 is a sequence of m 9's, and multiplying by 10^n is the same as tacking on n 0's to the end, for the mechanical purposes of forming the fraction.

Posted by Charlie
on 20070926 10:37:45 