If c is a positive real number, then $g(n) = 1 + c + c^2 + ... + c^n $ is:
- $\mathcal{0}(1)$ if $\:c < 1$
- $\mathcal{0}(c^n)$ if $\:c > 1$
I see this post Geometric series and big theta.
But it shows case of c > 1.
How can I show the time complexity is o(1) if c < 1 ?
Let $ n\in\mathbb{N} $, and $ c\in\mathbb{R}\setminus\left\lbrace1\right\rbrace $, note that : $$ \sum_{k=0}^{n}{c^{k}}=\frac{1-c^{n+1}}{1-c} $$
If $ \left|c\right|<1 $, then : $$ \frac{1-c^{n+1}}{1-c}\underset{n\to +\infty}{\longrightarrow}\frac{1}{1-c} $$
Meaning, in this case : $$ \sum_{k=0}^{n}{c^{k}}=\underset{\overset{n\to +\infty}{}}{\mathcal{O}}\left(1\right) $$
If $ \left|c\right|>1 $, then the sequence $\left\lbrace\frac{c^{n+1}-1}{c-1}\right\rbrace_{n} $ diverges, and : $$ \frac{c^{n+1}-1}{c-1}=\underset{\overset{n\to +\infty}{}}{\mathcal{O}}\left(c^{n}\right) $$