Solution:
The main trick is finding a closed-form expression for an, which requires some experimentation. We will show that an=(22n+1+1)/3 for all n by induction. It is easy to check that the formula holds for n=1. And if it holds for some n, then
an+1=23an2+1−an=21(3[322n+1+1]2+1)−322n+1+1=21(3(22n+1)2+2(22n+1)+1+1)−322n+1+1=21(322n+1+2+2(22n+1)+4)−322n+1+1=322n+1+1+22n+1+2−322n+1+1=322n+1+1+1,
giving the induction step.
Now, by Euler's theorem, 3k divides 22⋅3k−1−1, for any nonnegative integer k, since ϕ(3k) (i.e. the number of integers in {1,2,…,3k} relatively prime to 3k) equals 2⋅3k−1. But notice that 22⋅3k−1−1=(23k−1−1)(23k−1+1), and 3k−1 is odd ⇒23k−1≡2(mod3)⇒23k−1−1 is relatively prime to 3k, so, in fact, 3k divides 23k−1+1. Also, for any integers c,d with d odd, 2c+1∣2cd+1. We conclude that 3k∣2a+1 whenever 3k−1∣a and a is odd.
Applying this result twice in succession, we find that 3k∣23k+1 and then that 3k+1∣223k+1+1, so that 3k∣(223k+1+1)/3=a3k for any integer k≥0, and this is what we wanted to prove.