How to determine, does it include the period the result of dividing Zelig numbers?

Dear forum, help to write an algorithm that would process the fractional part of the result of dividing the integer number by an integer, namely, it is necessary to be in the right place to put parentheses as in the examples. The maximum number of digits after the dot = 10.

For example:
1000 / 3 = 333.(3)
7 / 12 = 0.58(3)
25/39 = 0.(641025)
June 10th 19 at 16:27
1 answer
June 10th 19 at 16:29
Solution
First, separate the integer part of the fraction.
The rest are entered in the array.
Then in a loop domogala balance 10, division find the next digit of the fractional part and another the rest.
If this residue already present in the array, then roll a loop, can be interrupted and put brackets since discovered in the array position.
Example:
Fraction | Whole | the Rest | the Result of | an Array of residues
 | part |
 25/39 | 0 | 25 | 0. | 25
250/39 | 6 | 16 | 0.6 | 25, 16
160/39 | 4 | 4 | 0.64 | 25, 16, 4
 40/39 | 1 | 1 | 0.641 | 25, 16, 4, 1
 10/39 | 0 | 10 | 0.6410 | 25, 16, 4, 10
100/39 | 2 | 22 | 0.64102 | 25, 16, 4, 10, 22
220/39 | 5 | 25 | 0.641025 | ---

In the last step we got the rest already existing in the array at the zero position. So an opening parenthesis is added immediately after the point.
0.(641025)
Brilliant. Thank you. - taya.Christiansen commented on June 10th 19 at 16:32

Find more questions by tags Algorithms