\begin{align*} 3^0 \equiv 1\mod 7\\ 3^1 \equiv 3\mod 7\\ 3^2 \equiv 2\mod 7\\ 3^3 \equiv 6\mod 7\\ 3^4 \equiv 4\mod 7\\ 3^5 \equiv 5\mod 7\\ 3^6 \equiv 1\mod 7\\ 3^7 \equiv 3\mod 7\\ \end{align*}
Now just focusing on 1, 3, 2, 6, 4, 5, 1.... How to devise a formula to find the next number. Like if 2 is given how to find 6 or if 4 is given how to find 5? I am looking for an explicit function.