How to know without factoring whether a division will result in recurring decimals

285 Views Asked by At

Assumption: When dividing an integer n by another integer m, and representing the result as a decimal in base b, it will have recurring decimals iif m has at least a prime factor that's not in n, and it's not common with b.

Examples:

  • 6 / 100 when represented in base 10 it does not (0.03), because 100 = 2*2*5*5, in which all factors are common with the ones of base 10 (2 and 5).
  • 100 / 6 in base 10 does have recurring decimals (16.6666....), because 6 = 2*3, which has 3 that's not common with the ones of base 10
  • 300 / 6 in base 10 on the other hand doesn't have recurring decimals (50), because the 3 factor gets cleared out as it's common with the numerator.

These also apply when representing the number in any other base.

However, I need to figure this out working with numbers that are big, and that are not integers, but rational numbers, which I have represented as decimals.

So to use this method, I'd have to first transform each number to the rational representation a / b by using the continued fraction method (which is already a long algorithm), then factor each number (which will probably be too big to do efficiently), then compare the factors using the method above to get the binary answer.

So I would like to know if there's any way to tell whether the result will have recurring decimals without having to factorise the original ones. As possible not-so-big example inputs (all in base 10 to make thinking easier):

  • 3.94625 / 3 does result in recurring decimals: 1.3154166666...
  • 3.5623086 / 3: doesn't result in recurring decimals: 1.1874362