# Is there a formula for a sequence like $k^{t}-k^{t-1}+k^{t-2}-…+k^{2}-k^{1}+k^{0}$

I am trying to solve a programming problem and my intended solution involves a calculation like this one:

$k^{t}-k^{t-1}+k^{t-2}-...+k^{2}-k^{1}+k^{0}$

The problem is that $t$ can be as large as $1,414,213,562$ so iterating isn't an option. Does anyone know of a formula for this?

• en.wikipedia.org/wiki/Geometric_series – lab bhattacharjee Dec 20 '13 at 18:48
• This looks like an alternating geometric sequence to me. – Module Dec 20 '13 at 18:49
• Hint: The ratio between terms (r) is $-k$. The formula for geometric sum is $\frac{t_{1}\left( 1-r^{n} \right)}{1-r}$. – 1110101001 Dec 20 '13 at 19:03

You look for $$\sum_{p=0}^t (-k)^p=\frac{1-(-k)^{t+1}}{1+k}$$
• $\ddot \cup +1$ – Namaste Dec 21 '13 at 17:49