Problem

Source: SRMC 2023, P3

Tags: number theory, prime numbers, Quadratic Residues, Directed graphs, quadratics



Let $p$ be a prime number. We construct a directed graph of $p$ vertices, labeled with integers from $0$ to $p-1$. There is an edge from vertex $x$ to vertex $y$ if and only if $x^2+1\equiv y \pmod{p}$. Let $f(p)$ denotes the length of the longest directed cycle in this graph. Prove that $f(p)$ can attain arbitrarily large values.