N =[Log(L/F) / Log(R)] + 1, where N=Number of terms, L=Last term, F=First term, R=Common Ratio.
N =[Log(512/2) / Log(2)] + 1
N = 9 - this is the number of terms. Then sum it up as Geometric Series:
First term =2
Common Ratio = 2
Number of terms =9
You should get S = 1,022