First, we shall show that 3∈/S by proving that
a3k−2≡2(mod3), a3k−1≡2(mod3) and a3k≡2(mod3).
Since a1=1, a2=2, a3=22+2⋅2=8≡2(mod3) so the claim is true for k=1.
Suppose that the claim holds for k=n. We have
a3n+1a3n+2a3n+3=a3n(a3n+3n)≡2⋅2≡1(mod3),=a3n+1(a3n+1+3n+1)≡1(1+1)≡2(mod3),=a3n+2(a3n+2+3n+2)≡2(2+2)≡2(mod3).
Thus, the claim is also true for k=n+1. So by induction, the claim is proved.
Now suppose on the contrary that S is finite, denote S={p1,p2,…,pk}. Note that an∣an+1 so an∣am for all m≥n. By the definition of S, there are some index t such that p1∣at, thus p1∣at′ for all t′≥t. Similarly for p2,p3,…,pk so there exist N big enough such that p1p2⋯pk∣an for all n≥N. Taking the integer ℓ>N+1 such that ℓ≡2(modp1p2⋯pk). Since aℓ=aℓ−1(aℓ−1+ℓ−1), we get
aℓ−1+ℓ−1≡1(modp1p2⋯pk)
so aℓ−1+ℓ−1 is coprime to all primes in S, which implies that S has some prime divisor that not belong to S, a contradiction. Hence, S is an infinite set. □