The characteristic equation is

r − 3 = 0

The solution is r = 3. The homogeneous recurrence has general solution

an = c13n

A particular solution is

an = c2n + c3

for some constants c2 and c3.

Since a0 = 2 and a1 = 3a0 + 1 = 7,

 2 = a0 = c2(0) + c3.
 7 = a1 = c2(1) + c3.

The first equation tells us that c3 = 2. Then the second equation tells us that 7 = c2 + 2, or c2 = 5. So the particular solution is

an = 5n + 2.

Notice that a2 = 3a2 + 2 = 3(7) + 2 = 23. Our particular solution gives a2 = 5(2) + 2 = 12, which is not correct. The problem is that we need to add a term corresponding to the solution to the homogeneous equation. We get

an = 5n + 2 + c13n

for some constant c1. Since a2 = 23,

 23 = a2 = 5(2) + 2 + c132

telling us that c1 = 11/9. The final solution is

an = 5n + 2 + (11/9)(3n).