Hi anon, thanks for that answer 
I have NOT checked you logic, I have only coded it so it is more easily read 
Perhaps you shoulod just check that what i have written is what you intended :)
--------------------------------------------------------------------------------------------
I give this a try(pls someone check this afeter I done)
Let the term $$S_n$$ be the sum of the first $n$ powers of $2$. For instance, $$S_3 = 2^0 + 2^1 + 2^2 = 7$$
Find the largest possible value of the greatest common divisor of two consecutive terms, $S_n$ and $S_{n+1}$, for any $n$.
$$\\Sn=2^0+2^1+2^2+.......2^{n-1}\\\\
$consider the pattern$ \\\\
2^0=\frac{(2^1-1)}{2-1}\\\\
2^0+2^1=\frac{(2^2-1)}{(2-1)}\\\\
2^0+2^1+2^2=\frac{(2^3-1)}{(2-1)}\\\\
2^0+2^1+2^2+2^3=\frac{(2^4-1)}{(2-1)}\\\\\\
2^0+2^1+2^2+2^3.......+2^{n-2}+2^{n-1}=\frac{(2^n-1)}{(2-1)}\\\\
2^0+2^1+2^2+2^3.......+2^{n-2}+2^{n-1}+2^n=\frac{2^{n-1}-1}{(2-1)}\\\\
S{n}=2^0+2^1+2^2+2^3.......+2^{n-2}+2^{n-1}=2^{n}-1\\\\
S{n+1}=2^0+2^1+2^2+2^3.......+2^{n-2}+2^{n-1}+2^n=2^{n+1}-1\\\\
$so the greatest common divisor would be $2-1=1\\\\$$
.