Consider the equation $n^2 = -1 \mod (p_n-1)(*)$ where $p_n > n$ and $f(n) = p_n$ is the largest prime that satisfies the equation.
$f(n)$ gives $p_n$ assuming there is a solution to the equation $(*)$, otherwise it gives $0$.
$g(n)$ is the $n$th value for which $f(g(n))$ gives a nonzero value.
Im curious about the sequences $g(n)$ and $p_{g(n)}$.
For instance what is their growth rate ?