How do you compute $\operatorname{ind}_r a$? $\newcommand{\ind}{\operatorname{ind}}$
Let $m = 13$ and $r = 2$.
So I want to compute
$$\ind_2 1$$
$$\ind_2 2$$
$$\ind_2 3$$
$$\vdots$$
$$\ind_2 12$$
To start I know that $1 \le \ind_r a \le \phi(m) = 13 - 1 = 12$. So the possible values are $1, 2, 3,\ldots,12$.
Right now I just know how to do it the naive way, which is just the brute force of trying all the exponents from $1,\ldots,12$.
So for example $\ind_2 1 = 12 => 2^{12} \equiv 1 \mod 13$.
Is there a better way than plugging in all the values and using a calculator?
 A: Since you want all of the indices, there is nothing more efficient than computing $2^1$, $2^2$, $2^3$, $2^4$, and so on, all modulo $13$. We get $2^1\equiv 2$, $2^2\equiv 4$, $2^3\equiv 8$, $2^4\equiv 3$, $2^5\equiv 2\cdot 3\equiv 6$, $2^{6}\equiv 12$, and so on. 
So , reading the table backwards, we get $\operatorname{ind}_2 (2)=1$, $\operatorname{ind}_2 (4)=2$, $\operatorname{ind}_2 (8)=3$, $\operatorname{ind}_2 (3)=4$, $\operatorname{ind}_2 (6)=5$, and so on.
Remark: Recall that in our context $\operatorname{ind}_2 (x)$ is the smallest positive integer $k$ such that $2^k\equiv x\pmod{13}$.    It can be viewed as a kind of logarithm to the base $2$, modulo $13$. Since $2$ a primitive root modulo $13$, for every $x$ with $1\le x\le 12$, there is a unique $k$ between $1$ and $12$ such that $2^k\equiv x\pmod{13}$. This $k$ is called $\operatorname{ind}_2 (x)$.
If we have a primitive root $g$ of a very large prime, the index $\operatorname{ind}_g (x)$  appears to be difficult to compute. This accounts for the importance of the index ("discrete logarithm") in cryptography.  There are quite a number of algorithms that are (much) better than the try everything approach. The Wikipedia article on the discrete logarithm mentions several. But if we want *all the indices modulo $p$, one can't beat computing all the powers of $g$ modulo $p$, and sorting that list.
