2

To check that a rational number is in the Cantor set, I have written an algorithm to obtain its base-3 representation. To verify if the representation is periodic, I used a hash table in order to save memory.

Is there any easier solution to check that a rational number is in the Cantor set?

aco
  • 21
  • 1
  • You can probably compute the period in advance. Check an elementary number theory text. – Yuval Filmus Feb 06 '17 at 23:30
  • @Yuval Filmus Would that help? If the denominator is $d$, assuming $d$ isn't a multiple of 3, the period has length $m$ where $m | ord_3(d)$. In the worst case, $d$ is prime and 3 is a generator of $\mathbb{Z}_d^*$, yielding $m = d-1$. That would be the same as doing long division by hand. – quicksort Feb 07 '17 at 04:29

0 Answers0