I am trying to write a simple repeating decimal algorithm. Now I'm almost close to what works.
I tried to use this algorithm: How to find out the repeated decimal number in a fraction?
"A very simple algorithm: implement a long division. Each intermediate division you do. As soon as you see a section identical to the one you did before, you have what was repeated."
I was able to do all of the above except detecting a repeating decimal pattern and placing it in brackets.
For fraction 7/13, my conclusion should be 0. [538461] right now it's 0.5,3,8,4,6,1,5,3,8,4,6,1,5,3,8,4 6.1.5.
Any suggestions on how to implement duplicate decimal pattern detection and put it in brackets using the algorithm mentioned above? I know there are similar questions, but I would like to implement it with my current code using the algorithm mentioned above.
<script> </script>
user1822824
source share