formula for converting a very long number to a fraction

7.6k Views Asked by At

What is the average (arithmetic mean) of 8, 7, 7, 5, 3, 2, and 2?

the answer is $4\frac{6}{7}$.

The sum of numbers is 34 and when you divide by 7 it's 4.8571428.....

How can I get the fraction of above number?

3

There are 3 best solutions below

0
On

A decimal expansion can be converted to a sequence of best rational approximations by an application of continued fractions.

The basic idea is to subtract off the integer part, and then reciprocate the fractional part. The result will have a nonzero integer part, and the process can be continued until the fractional part is zero (or forever, if the number is not rational).

Here we take the following steps, ignoring for the sake of illustration the "dot..dot..dot" portions of the number:

$x_0 = 4 + 0.8571428...$

$x_1 = 1/0.8571428 = 1 + 0.16666674444...$

$x_2 = 1/0.16666674444 = 5 + 0.99999720016...$

Notice that this $x_2$ is very nearly $6$, suggesting that if full precision had been used we would get exactly $6$ and the process would halt there.

Putting the pieces together we have $4 + \frac{1}{1 + \frac{1}{6}} = 4 \; \frac{6}{7}$.

0
On

The simple answer is to multiply the decimal by the denominator and round. You have $ 0.857128 \cdot 7 = 5.9999996$, so the fraction is $\frac 67$ Works great if you know the denominator.

0
On

Aren't we missing something here? Surely $34/7$ is a repeating decimal, as the "$857142$" after the decimal point repeats indefinitely. Using high school math we denote $x=4.857142...$ and $10^6x=4857142.857142...$. Subtracting $10^6x-x=999,999x=4857138$. so, the fraction the OP is looking for is $4857138/999999$.