Possible Duplicate:
How to know the repeating decimal in a fraction?
1/3 is different by 3/10. 0.33333 != 0.3
So 1/3 will be 0.3 (with a line above number three)
1/12 = 0.833333 = 0.083 (with a line above number three)
1/13 = 0.076923076923 = 0.|076923|
Those lines represent the repeating part.
I plan to have this model in a class. I'm a bit lost on this situation. I just need some ideas to know determine the repeating value. Thanks.
Cycle detection algorithm is the answer. You can use Floyd's cycle detection algorithm or Brent's cycle detection algorithm.
The function to plug into those algorithms is the function to produce the next digit of the quotient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With