I am trying to teach myself about p-adic numbers, and I came across an interesting property. Consider the following expansions:

In the case of , the repeating pattern is two digits, and similarly for negative two-thirds. In the case of the six expansions where the denominator is nine, the six digits shown repeat to the left. I understand multiplying by powers of 2 is essentially bit shifting, so those all make sense, but and . In other words, to get all rotations of the repeated digits, you simply multiply by all powers of 2 mod 9. This works when the denominator is 27 as well (there are 18 digits that repeat infinitely to the left, and 18 units of the local ring , and the operation of multiplication by 2 mod 27 does indeed rotate the 18 digits). Is there a way to prove this works when the denominator is any power of 3? I can prove that the number of repeated digits in the 2-adic expansion of is . This is actually relatively simple since a simple induction argument shows that always divides and

Then, since , which is a positive integer, its base-2 expansion takes at most digits, so the expansion repeats that many digits. Also, since multiplying by any power of 2 mod will give a unit of , multiplying the whole fraction by that unit will still take no more than digits to express in base-2, so that is still the number of repeating digits. I just don't have any idea how to show that you always get a rotation of the digits.

Edit: I am guessing the Division Algorithm might be useful. Consider the following:

has the solution . Now, where the six digits to the left of the five zeros adjacent to the decimal point are the repeated digits. Essentially, I just bit-shifted five places to the left. Now, which is also . I am not quite sure how to relate this to the rotation, though.