The third term is what the sum gains on the third step: a3=S3−S2=21−9=12. Writing the terms as a, ar, and ar2 gives two equations.
a(1+r)=9,ar2=12
Substituting a=9/(1+r) into the second gives 9r2=12(1+r), that is 3r2−4r−4=0, which factors as (3r+2)(r−2)=0.
r=2orr=−32
The problem asks for the positive ratio, so r=2, and the sequence 3,6,12 does give S2=9 and S3=21.