How find the postive $m,n$,such $a^n\equiv 1\pmod m$ Find all positive integer pairs $(m,n)$ with $m,n \ge 2$ such that for all $a\in\{1,2,\cdots,n\}$, $$a^n\equiv 1\pmod m$$


If $(a,m)=1$, Euler's Theorem tells us that 
$$a^{\phi(m)}\equiv 1\pmod m.$$
So one family of solutions is $(n,m) = (\phi (m), m)$. Is it possible to describe all families?
A proof based in the roots of $X^n-1$


  Answer: The only pairs satisfying your statement are $(p,p-1)$ for primes $p$


Given a pair of integers $(m,n)$ such that $n&gt;1$ suppose that for every $k\in\{1,\cdots,n\}$ we have:
$$k^n\equiv 1 \mod m\tag1$$
As noticed by Barry Cipra $n$ must be smaller than $p$ the smallest prime divisor of $m$ because $p^{n}\not\equiv 1\mod m$ hence $n&lt;p$, And as consequence of $(1)$the roots of $x^n-1$ in $\Bbb Z_p$ are exactly $1,\cdots,n$. 

Now let's prove that $n\geq p-1$, by contradiction, assume that $n&lt;p-1$:


If $n$ is even then $p-1$ is another root of $x^n-1$ in $\Bbb Z_p$ which is absurd.
If $n$ is odd then $n+1=2a$ with $a,2\leq n$ hence $n+1$ is another root of the polynomial ($2^n\equiv 1\mod p $ and $a^n\equiv 1\mod p$ implies $(n+1)^n\equiv 1\mod n$) which is absurd.


As a conclusion $n=p-1$. Now given another prime $q$ which divides $m$, we can prove using the same method (as we did for $p$) that $n\geq q-1$ and because $n=p-1$ we have $p=q$.
If $m$ is divisible by $p^2$, we know that:
$$(p-1)^{p-1}\equiv -p(p-1)+1 \mod p^2 $$
which is absurd because $(p-1)^{p-1}\equiv 1\mod m\equiv 1\mod p^2$ hence $m=p$

Finally we proved that $n=p-1$ and $m=p$ is aprime
You are looking for something called the "order" of an element belonging to the set of integers modulo m. Now, this term comes from abstract algebra, as the order of an element in some group (don't worry about the axioms for being a group, just know that the set of residues mod m is a group) is the exponent $k$ such that $a^k = e$. 

Now, $e$ denotes the identity element of a group under some operation. In our case, this is the identity element of the integers under multiplication. This is pretty clearly seen to be 1. Thus, the order of some element modulo m is the integer $k$ such that $$a^k \equiv 1 (\bmod m)$$ Now, as you probably know, a is restricted to being a member of the reduced residue set modulo m, as in, any integer such that $(a,m)=1$. Thus, for $a$, we have $\phi (m)$ choices for a. Now, the integer $a$ such that $$a^{\phi (m)} \equiv 1 (\bmod m)$$ is known as a primitive root in number theory, or, a generator of the cyclic group of reduced residues modulo m in abstract algebra. So, you have the primitive roots, and then you have the elements of order $k &lt;\phi (m)$. An element cannot have an order greater than $\phi (m)$. 

Something to note is that the order of an element must divide $\phi (m)$. This can easily be proven using the division algorithm for $\phi (m)$, rewriting is as $kq+r$, and showing that $r=0$. 

Another important theorem asserts that for any $prime$ modulus, the amount of primitive roots mod m is $\phi (p-1)$, where $p$ is prime. This can help you narrow down the rest of the coprime elements. Also, for checking the order of elements, since you know that the order must divide your phi function, it is only necessary to check powers that are divisors of $\phi (n)$, which is significantly faster.

I won't prove them (unless you really want..), but there are two theorems that are pretty helpful for moduli of certain forms. Firstly, for any odd $a$, $$a^{\phi (2^{\alpha})/2} \equiv 1 (\bmod 2^{\alpha})$$

And then we also have a theorem asserting that a primitive root exists if and only if $m = 1, 2, 4, p^{\alpha}$ or $2p^{\alpha}$, where m is you modulus. 

Now, I'm not sure exactly what you meant by families, but I can say that the order of any element modulo m will divide $\phi (m)$, so the families would be all elements that have an order of a divisor of $\phi (m)$.