Let $p$ be a prime number different from $2$ and $5$. This implies that $p$ is coprime to $10$.
Fermat's little theorem states that $$10^{p-1}\equiv 1\mod p$$ is satisfied. If for every prime factor $q$ of $p-1$, we have $$10^{\frac{p-1}{q}}\ne 1\mod p$$ we can conlude that $p-1$ is the smallest exponent such that the above equivalence holds.
For example : $$p=17$$ $$p-1=2^4$$ $$3^8\equiv 16\mod 17$$
So, $10$ is a primitive root modulo $17$, so the period has length $16$
$$p=31$$ $$p-1=2\cdot 3\cdot 5$$ $$10^{15}\equiv 1\mod 31$$
So, $10$ is not a primitive root modulo $31$. The period has length $15$ in this case.
In general, the length of the period is $ord_p(10)$
The period lengths for the primes upto $200$ :
? forprime(j=1,200,if(gcd(j,10)==1,print(j," ",znorder(Mod(10,j)))))
3 1
7 6
11 2
13 6
17 16
19 18
23 22
29 28
31 15
37 3
41 5
43 21
47 46
53 13
59 58
61 60
67 33
71 35
73 8
79 13
83 41
89 44
97 96
101 4
103 34
107 53
109 108
113 112
127 42
131 130
137 8
139 46
149 148
151 75
157 78
163 81
167 166
173 43
179 178
181 180
191 95
193 192
197 98
199 99
?