In order to know A2 = 6, A5 = 162 in the equal ratio sequence {an}, find the first n terms and Sn of the sequence {an}

In order to know A2 = 6, A5 = 162 in the equal ratio sequence {an}, find the first n terms and Sn of the sequence {an}

Because an is an equal ratio sequence, A5 = A2 * q ^ 3 162 = 6q ^ 3
q=3
a1=a2/q=6/3=2
an=a1q^(n-1)=6*3^(n-1)=2*3^n
sn=a1(1-q^n)/(1-q)
242=2*(1-3^n)/(1-3)
n=5