2 ms·
(This was meant to be appended as an edit to the above, but between the time I started typing it into the update text area and the time I hit the "update" butto
by tzs 10y ago
(This was meant to be appended as an edit to the above, but between the time I started typing it into the update text area and the time I hit the "update" button the comment aged enough to not allow updates, so I'll add it as a reply)
In general, a necessary (but not sufficient) condition for the representation of n/m to be precisely represented in base b is that there exists some integer r in [1, m-1] such that rb = 0 mod m. If you work out the representation of n/m using the classic division algorithm, the algorithm terminates iff you hit such an r after one of the subtraction steps. The step on which you hit that r will have produced the next to less digit of the result, and then the algorithm will product one more digit and terminate.
When m is a prime (such as m = 3), then (r, m) = 1, and so rb = 0 mod m is only possible if b = 0 mod m. If b = 0 mod m then all r are suitable, and n/m has at most one digit after the radix point.