I have a sequence of numbers 0, 1, 5, 19, .... This is the pseudocode to generate the sequence
$c = 0$
for $i=0, 1, 2, ...:$
$ c = 3c + 2^i$
Does anyone know how I would write an equation $f(i)$ that would generate this same sequence?
Thanks
I have a sequence of numbers 0, 1, 5, 19, .... This is the pseudocode to generate the sequence
$c = 0$
for $i=0, 1, 2, ...:$
$ c = 3c + 2^i$
Does anyone know how I would write an equation $f(i)$ that would generate this same sequence?
Thanks
The generating function is $$f(n)=3^n-2^n$$
Proof by induction : The base case $n=0$ is clear.
Now, we have $$3^{n+1}-2^{n+1}=3\cdot(3^n-2^n)+3\cdot 2^n-2^{n+1}=3\cdot(3^n-2^n)+2^n$$
So, we have $f(n+1)=3f(n)+2^n$, completing the proof.