Define bn=(a1+1)(2a2+1)⋯((n−1)an−1+1) for n=2,3,… and let b1=1. By using mathematical induction we will prove that for all positive values of n
bn+1=(b1+2b2+⋯+nbn)2−5(1)
For n=1 we have b2=a1+1=−4 and hence b2=−4=b12−5 and (1) holds. Assume that (1) holds for n=k−1. Then we have bk=(b1+2b2+⋯+(k−1)bk−1)2−5. In order to prove that (1) is held for n=k we show that
bk+1−bk=k2bk2+2kbk(b1+2b2+⋯+(k−1)bk−1)(2)
By definition of bn, we have an+1−an=(a1+1)(2a2+1)(3a3+1)⋯((n−1)an−1+1)((n2+n)an+2n+1)=(n+1)bn+1+nbn. Hence we obtain that
ak−a2=i=3∑kai−ai−1=j=3∑kjbj+(j−1)bj−1=kbk+2(3b3+4b4+⋯+(k−1)bk−1)+2b2.
Since a2=−6, b1=1, b2=−4, we conclude that ak−kbk=2(b1+2b2+⋯+(k−1)bk−1). Therefore
kbkbk+1−bk−kbk=2(b1+2b2+⋯+(k−1)bk−1)
and (2) is held. Thus, (1) is proved. Now if p is a prime number dividing nan+1, then p also divides bn+1 and therefore we can choose m=b1+2b2+⋯+nbn and in this case p divides m2−5=bn+1.