<s>[INST] geometric series used to work out big O notation for resizing an array in a stack It's a geometric series
$$
1 + 2 + 4 + \cdots + 2^k =  \frac{1 - 2^{k+1}}{1 - 2}
$$
Here, $2^k$ = N. You get $1 + 2 + 4 + \cdots + N = \frac{1 - 2N}{-1}$. Therefore, $2 + 4 + \cdots + N = 2N−2$. When $N$ is big, you can just drop the $−2$ to get big $O$ notation.
Above is the working out I was given. The array is doubled once it is full. So when an array of size 1 has 1 item, the array doubles to size $2$. What I am trying to find out is why
$$
  1 + 2 + 4 + \cdots + 2^k = \frac{1 - 2^{k+1}}{1 - 2}
$$
and $2^k = N$. I was wondering if step by step workings can be shown and an explanation.
 [/INST] $$S=1 + 2 + 4 + \cdots + 2^k 
\\2S= 2 + 4 + \cdots + 2^k+2^{k+1} 
\\S-2S=1-2^{k+1} 
\\S(1-2)= 1-2^{k+1}
\\S= \frac{1 - 2^{k+1}}{1 - 2}$$
</s>