Question 30
Let $k$ be a positive integer and set $n=2^{k}+1$. Prove that $n$ is a prime number if and only if the following holds: there is a permutation $a_{1}, \ldots, a_{n-1}$ of the numbers $1,2, \ldots, n-1$ and a sequence of integers $g_{1}, g_{2}, \ldots, g_{n-1}$ such that $n$ divides $g_{i}^{a_{i}}-a_{i+1}$ for every $i \in\{1,2, \ldots, n-1\}$, where we set $a_{n}=a_{1}$.