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?
You look for $$\sum_{p=0}^t (-k)^p=\frac{1-(-k)^{t+1}}{1+k}$$