Re: Cyclical Decimal Expansion
- To: mathgroup at smc.vnet.net
- Subject: [mg114495] Re: Cyclical Decimal Expansion
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 5 Dec 2010 21:56:22 -0500 (EST)
The answer is classical and is (or rather used to be) taught in elementary number theory classes. Here is how to compute it with Mathematica: Consider a fraction of the form p/q in reduced form. Use FactorInteger to factorize it into the form 2^a 5^b Q ,where we have GCD[Q,10]====1. Let m== Max[a,b]. Then in the decimal expansion of p/q will get m non-recurring digits, while the number of recurring ones depends only on Q and is given by the Mathematica function MultiplicativeOrder[10,Q]. For example. in the case 1/7 there are no non-recurring digits and the number of recurring ones is: In[342]:== MultiplicativeOrder[10, 7] Out[342]== 6 Andrzej Kozlowski On 3 Dec 2010, at 11:21, Harvey P. Dale wrote: > What's the easiest way to determine the length of the repeating > cycle for decimal expansions of fractions? For example, 1/7 == > 0.14285714285714285714 . . . so the length of its repeating cycle > (142857) is 6. For 1/3 the length of the cycle is obviously 1. For > some fractions, e.g., 1/4, the decimal expansion is not cyclical (in > base 10). > > Thanks. > > Harvey > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ >