# Finding all values of $n$ for which $1/n$ has a specific decimal period in different bases

I wanted to know if there is a way to easily determine the lowest value Natural number $$n$$ to where $$1/n$$ decimal actual period is purely repeating to $$5$$ digits in base $$5$$ and purely repeating to $$4$$ digits in base $$6$$?

What I learned so far

I had seen where $$n$$’s decimal representation independent of the base if the fraction is in lowest terms (is why I choose $$1/n$$) the period is limited to some $$n-1$$ or an integer $$n-1$$ is divisible by. It does not give the way to actually determine the period and it states the period may well be different for other bases.

For example $$1/33$$ could have periods of ($$1,2,4,8,16,$$ or $$32$$).

So my guessing point is lowest $$n$$ would need to be some multiple of $$20$$ then adding one also not having $$2,3$$ or $$5$$ as a prime factor to insure purely repeating for all chosen bases.

However I also saw for the denominator of $$33$$ that a period length of $$10$$ was given even though $$33-1$$ has no factors of $$5$$ in it so am left wondering if that theorem is actually true.

For your first problem, the answer is that no such $$n$$ exists. Indeed, the base $$6$$ expansion having period $$4$$ tells you $$n$$ is a factor of $$6^4-1=5\times 7\times 37$$, and the base $$5$$ having period $$5$$ gives $$n$$ divides $$5^5-1=2^2\times 11\times 71$$. You can see these are incompatible constraints.

Now your confusion with $$n=33$$ seems to come from applying a theorem outside its domain

Theorem 1 Let $$p$$ be prime. The fundamental period of $$1/p$$ in base $$b$$ expansion, $$b$$ not divisible by $$p$$, is a factor of $$p-1$$.

This need not work for $$n$$ composite. Indeed, the above is derived from

Theorem 2 The minimal period of $$1/n$$ in base $$b$$ expansion, $$\gcd(n,b)=1$$, is the multiplicative order of $$b$$ modulo $$n$$.

Since the multiplicative group $$(\mathbb{Z}/p)^\times$$ has order $$\phi(p)=p-1$$, this gives the case $$n=p$$ is prime.

• What is then the period constraints for an unreducable fraction (non factors of 3,11)/33 The table I thought was referring to fractions already in lowest terms – Toni Stack Nov 10 '18 at 1:35
• In general, the order has to be a divisor of $\phi(n)$, where $\phi$ is the Euler's totient function. But it is possible to give a slightly stronger bound -- it has to be a divisor of $\operatorname{lcm}(\phi(p_1^{r_1}),\phi(p_2^{r_2}),\dots,\phi(p_k^{r_k}))$, where $n=p_1^{r_1}p_2^{r_2}\dots p_k^{r_k}$. In your case, 33=3*11 and $\phi(3)=2$, $\phi(11)=10$ gives lcm =10. – user10354138 Nov 10 '18 at 2:44