1

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
  • $300/6$ does have a recurring decimal of .0000... – Clyde Kertzer Apr 21 '22 at 15:23
  • In my opinion, the first step must be to express the quotient in terms of $$\frac{p}{q},$$ where $p$ and $q$ are each integers. So, $$\frac{3.94625}{3}$$ becomes $$\frac{394625}{(10)^5 \times 3}.$$ Then, since you are working in base $10$, and since $3$ is not a prime factor of $10$, you know immediately that the fraction will have have an infinite repeating decimal if and only $3$ does not divide $(394625)$. – user2661923 Apr 21 '22 at 15:32
  • @ClydeKertzer Well - The question you linked confirms the assumption I made at the top, but doesn't answer my question – Victor Oliva Apr 21 '22 at 15:53
  • @user2661923 I'm asking specifically to avoid factoring numbers, because that requires finding p + q, and then factoring the both of them.

    Applying the same method to the other example becomes more apparent of this problem:

    3.5623086 / 3 = 35623086 / (10^7 x 3), yet it doesn't have recurring decimals because 3 is a factor of 35623086 = 2 × 3 × 47 × 126323.

    So you have to factorise both p and q. My question is - is there any way around this?

    – Victor Oliva Apr 21 '22 at 15:57
  • Wait, I see - it does get close. 10^n can always be ignored. Only q needs to be factorised, and ignoring every prime present in the base (in this case 10), we only need to check whether q divides p, which can be done through Euclidean algorithm. So p doesn't need to be factorised, but q does. – Victor Oliva Apr 21 '22 at 16:02
  • 2
    By here in the dupe (case $c =0$) the fraction $r$ terminates in radix $b\iff $ its lowest terms denominator $d$ divides some power of $b$, i.e. $,b^n r\in\Bbb Z,,$ for some $n,,$ i.e. $r$ can be written with denominator $,b^n.,$ This can be tested using only fast gcds (no slow factoring) by repeatedly cancelling $,\gcd(d,b),$ from $d$ till they are coprime. If the final value of $d = 1$ then $,d\mid b^n,$ for some $n$ so it is terminating; else it is repeating. – Bill Dubuque Apr 21 '22 at 17:13
  • @BillDubuque thank you, that's exactly what I was looking for - Clear explanation on how that applies here – Victor Oliva Apr 21 '22 at 20:23

0 Answers0