Divisibility rules with prime number Let $n \in \mathbb{Z}$ with the property that
$$
7 \mid\left(n^{3}+1\right)
$$
but $7$ does not divide $\left(n^{2}-2 n-3\right) .$ Prove that $7 \mid(4 n+1)$.
So far I got:
$n^3+1 = (n+1)\cdot(n^2-n+1)$, since $7$ is a prime, so
$7\mid(n+1)$ or $7\mid(n^2-n+1)$.
And since $7$ does not divide $\left(n^{2}-2 n-3\right) = (n-3)\cdot(n+1)$, I know that $7\mid(n^2-n+1)$.
And $7$ does not divide the difference of $(n^2-n+1)$ and $(n^2-2n-3)$ which is $n+4$.
Same since $7$ is prime, $7$ does not divide $4n+16\Rightarrow$$7$ does not divide $4n+2$.
Then I am stuck here, how could I use the information I got so far to prove $7 \mid(4 n+1)$?
Really hope someone could help/hint me with it! Thank you!
 A: Two methods:
Method 1
If $n^3\equiv-1\bmod 7$ then $n\in\{3,5,6\}\bmod 7$. But $n\in\{3,6\}$ renders $n^2-2n-3=(n+1)(n-3)\equiv0$, denied by hypothesis, and the last possibility $n\equiv5$ renders $4n+1\equiv0$.
Method 2
Multiply $n^2-2n-3$ by $4n+1$:
$(n^2-2n-3)(4n+1)=4n^3-7n^2-14n-3\equiv4(n^3+1)\bmod 7$
Thus if the prime number $7$ divides $n^3+1$ it must divide (at least) one of the factors $n^2-2n-3$ or $4n+1$.
A: Further factor $n^2 - n + 1 \equiv (n - 3)(n - 5) \mod 7$. Since $n - 3 \neq 0 \mod 7$, we see that $n - 5 \equiv 0 \mod 7$. So $n \equiv 5 \mod 7$. So $4n + 1 \equiv 0 \mod 7$.
A: This can be done more generally and algorithmically by a gcd as in the Lemma below.  Here $\,b = n^2\!-\!2n\!-\!3\,$ is coprime to $\,c=7\,$ so we can cancel out out any common factors $\,b\,$ has with $\, a = n^3+1\,$ without affecting divisibility of $\,a\,$ by $7.\,$ Computing the gcd $\!\bmod 7\,$ by the Euclidean algorithm we get $\, (a,b) = b,\,$ so  $\,7\mid a \iff 7\mid a/b \equiv n+2\iff n\equiv -2\,$ $\,(\Rightarrow 4n+1\equiv 0)$.
Lemma $\ $ If $\,(b,c) = 1\,$ then $\,c\mid a\iff c\mid a/(a,b)$
Proof $\ $ Since $\,b\,$ is coprime to $c$ it is also coprime to its factor $\,d=(a,b),\,$ so by Euclid's Lemma $\,c\mid a = da/d\iff c\mid a/d$
