Post Reply 
Repeating Decimals
01-13-2018, 12:22 AM
Post: #1
Repeating Decimals
How would I produce repeating decimals such as 142857 being repeated endlessly for 1/7. Some CASIO calculators do so including the fax-115ES PLUS and the Japanese version of the CLASSWIZ fox-991EX.
Find all posts by this user
Quote this message in a reply
01-13-2018, 12:23 AM
Post: #2
RE: Repeating Decimals
Spell check turned fx into fax and fox for the CASIO model prefixes!
Find all posts by this user
Quote this message in a reply
01-13-2018, 10:06 AM
Post: #3
RE: Repeating Decimals
(01-13-2018 12:22 AM)lrdheat Wrote:  How would I produce repeating decimals such as 142857 being repeated endlessly for 1/7. Some CASIO calculators do so including the fax-115ES PLUS and the Japanese version of the CLASSWIZ fox-991EX.

please, see if this routine by retoa helps.

Salvo

∫aL√0mic (IT9CLU), HP Prime, 50g, 41CX, 42s, 15C, 12C, DM42 :: Prime Soft. Lib
Find all posts by this user
Quote this message in a reply
01-13-2018, 06:09 PM
Post: #4
RE: Repeating Decimals
Thanks...I wish to go in the other direction...from a fraction to determine the repeating decimal.
Find all posts by this user
Quote this message in a reply
Today, 06:20 AM
Post: #5
RE: Repeating Decimals
Wow, you launched me into a delightful revisit to the old PPC days when we wrote programs called "infinite division" which essentially performed long division, outputting as many digits of a division as you asked for. It's easy; to get N digits of A/B you just calculate iquo(A*10^N,B), and if the result is too few digits you just tack on leading zeros.

Now we have to discern how many digits we should ask for. The decimal expansion of every ratio of integers has two parts after the decimal point: a sequence of digits which don't repeat (called the transient) followed by a sequence of digits which repeat (called the repetend). Example: 1/208 = 0.0048076923 with the underlined digits repeating forever. Here's how to determine that the transient is 4 digits long, and the repetend is 6 digits long.

First, factor out all 2's and 5's like this: 208 = 2^4 * 5^0 * 13. The powers of 2 and 5, as you can see, are 4 and 0. The length of the transient will always be the larger of those two powers (in this case, 4). This can be easily programmed. After factoring out the 2's and 5's, what's left is 13.

Next, find the multiplicative order of 10 (mod 13). It's always 10 because we are using base-10 ("decimal") notation. The 13 is from the previous paragraph. Finding the multiplicative order is not a simple task, but it's been programmed for the HP 50g and the algorithm would be the same on the Prime. The multiplicative order of 10 (mod 13) is 6. That's the length of the repetend.

So now we know that 1/208 consists of 4 non-repeating digits after the decimal point, followed by 6 repeating digits. All we have to do is use "infinite division" to crank out 10 digits of 1/208, and insert a symbol (such as an underscore) after the 4th digit, like this:

"0.0048_076923" which would mean 0.0048 followed by 076923 repeating forever.

Of course, if the repetend length is zero, then the decimal terminates, and the underscore symbol should not be inserted, e.g. 1/40 = 0.025 with no repeating part.

One benefit of using the above method is that it'll work for ANY fraction, no matter how many digits it has or how messy it might be. Anybody have time to code this for the Prime?

X<> c
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)