Avatar ·

The period of decimal fraction

📁 метод, python, пример

Task: Two integers are presented to the function of the function (int (a), int (b)) . You need to retu the private a/b , and the repeated numbers (period) need to be taken into brackets.

Examples:

   1 / 3  = & gt;    0.  ( 3 )   29 / 12  = & gt;   2.41  ( 6 )   5 / 3  = & gt;   1.  ( 6 )     

approached the problem of the problem of brushword. He sorted out the fractional part, searched for coincidences. But in the case of 1/117, the period includes more than 90 numbers and the overkill of numbers takes more time than is allowed in the problem.

How in a different way to solve this problem? Maybe there is a more elegant solution?