Integer long division: Difference between revisions

Content added Content deleted
m (start as a draft, fix up wp link, add another test case)
No edit summary
Line 1: Line 1:
{{draft task}}
{{draft task}}
Write a function that prints the result of the division of two integers with infinite precision (only limited by the available memory), stopping before the period starts repeating itself. Return also the length of this period (0 if there is no period).<br>
Write a function that prints the result of the division of two positive integers with infinite precision (only limited by the available memory), stopping before the period starts repeating itself. Return also the length of this period (0 if there is no period).<br>


Demonstrate it with the division 1/149, whose result is 0.0067114093959731543624161073825503355704697986577181208053691275167785234899328859060402684563758389261744966442953020134228187919463087248322147651, where the last 148 digits repeat endlessly. <br>
Demonstrate it with the division 1/149, whose result is 0.0067114093959731543624161073825503355704697986577181208053691275167785234899328859060402684563758389261744966442953020134228187919463087248322147651, where the last 148 digits repeat endlessly. <br>


The result could be stored as a string or simply output to the screen.<br>
The result could be stored as a string or simply output to the screen.<br>
Note that the division of any two numbers will always produce a period, but if the numerator is an exact multiple of the denominator, or if the denominator contains only the factors 2 and 5, the period will be 0. In the remaining cases, these possible 2's and 5's of the denominator produce a leading number of digits in the quotient, but have no effect on the period. <br>
Note that the division of any two integers will always produce a period, but if the numerator is an exact multiple of the denominator, or if the denominator contains only the factors 2 and 5, the period will be 0. In the remaining cases, these possible 2's and 5's of the denominator produce a leading number of digits in the quotient, but have no effect on the period. <br>


;References:
;References: