Problem

Source: Turkey TST 2014 Day 3 Problem 8

Tags: number theory proposed, number theory



$a_1=-5$, $a_2=-6$ and for all $n \geq 2$ the ${(a_n)^\infty}_{n=1}$ sequence defined as, \[a_{n+1}=a_n+(a_1+1)(2a_2+1)(3a_3+1)\cdots((n-1)a_{n-1}+1)((n^2+n)a_n+2n+1)).\] If a prime $p$ divides $na_n+1$ for a natural number n, prove that there is a integer $m$ such that $m^2\equiv5(modp)$