Converting Decimals to FractionsDate: 10 Jul 1995 11:31:28 -0400 From: Michelle Arseneau Subject: fractions Question: A certain fraction is converted to a decimal and the decimal representation is 0.6428571428571428571... What is the fraction? Date: 11 Jul 1995 22:13:25 -0400 From: Dr. Ken Subject: Re: fractions Hello there! There are other ways to do your problem than the one I chose, but I kind of wanted to get in some experience with doing computer searches, so I tried not to try to figure out your problem by hand and instead made up a computer algorithm that searches for the answer. I wrote it in a program called Mathematica. Here's the algorithm that I used: For[ n=1; d=2, Abs[n/d - 0.6428571428571428571] > .000000000000000001, If[n<d, n++, n=1; d++], ]; Print[n, "/", d] If you're not familiar with Mathematica (boy, is it a neat program. Very cool), here's an explanation of what the algorithm does. Basically, n is the numerator and d is the denominator. The first line says to start out with the fraction 1/2. Then it checks to see whether the fraction it's checking is within .000000000000000001 of .6428571428571428571, and if it is, the algorithm stops. If it's not, it tries another fraction. First it tries all the fractions with a denominator of 2, then with a denominator of 3, and so on. That's what that "If[...]" stuff is all about, it sets n and d to the next fraction's numerator and denominator. Then when it finds what it's looking for, it stops and prints out n and d with a / between them. And the answer is....(drum roll).... 9/14 !! There you have it. -K |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/