Solve for the first $n$ such that $f(n) = n^2 - 3n - 1 \equiv 0 \mod p $

139 Views Asked by At

We are given the following function $f(n) = n^2 - 3n - 1$ and we want the first $n \in \mathbb{N}$ such that $f(n) \equiv 0 \mod p$. We are also given that for some $p$, no such $n$ exists.

I'm not extremely familiar with this type of equation, so I first wrote it as $f(n) - pk = 0 \Leftrightarrow n^2 - 3n - 1 - pk = 0$ with $k \in \mathbb{Z}$.

This permitted me to write $n = \frac{3 \pm \sqrt{9 + 4(1+pk)}}{2}$, which means that we want $9 + 4(1 + pk) = a^2 \Leftrightarrow 13 + 4pk = a^2 \Leftrightarrow a^2 \equiv 13 \mod 4p$.

And the $a^2 \equiv 13 \mod 4p \ $ got me stuck.

So, my first question is, do you think that I took the good path to solve this problem (I doubt it a bit since this is almost a diophantine equation and I never used the quadratic formula for an arithmetic problem) and, if it is indeed a possible path to take, how do you solve $a^2 \equiv 13 \mod 4p$, and especially, how can you determine for which $p$ is this equation impossible?

Thanks in advance!