I don't know if I should call this a series, or sum, or what. I am not very good at math, which is why I am here. But i can describe it. It is for a CS algorithm.
I have a graph, with N nodes. N is my target value, I need to sum to N or as close to it as I can.
I must pick a starting value >= 4. I want the lowest possible starting value >= 4.
For each starting value, I iteratively double it, then reduce it by 2.
So, for example, if my target was N=70, and I tried a start value of 8, then iteratively I would get
8 14 26 50
and 50 is not very close to 70.
if I chose 9
9 16 30 58
so, that's a bit better.
thank you for any help.
If you want a formula:
Starting with $a_0$, you have $a_{n+1} = 2a_n - 2$. This is the combination of a geometric sequence and an arithmetic sequence. You can take successive values to find the pattern:
$a_1 = 2a_0 - 2$
$a_2 = 2a_1 - 2 = 2^2 a_0 - 4 - 2$
$a_3 = 2a_2 - 2 = 2^3 a_0 - 8 - 4 - 2$
And
$$a_n = 2^n a_0 - 2^n - 2^{n-1} - ... - 4 - 2 = 2^n a_0 - \sum_{i=1}^n 2^i$$
The second term is a geometric series, and we know from a formula that it is equal to $2^{n+1} - 2$. Therefore
$$a_n = 2^n a_0 - 2^{n+1} + 2$$
You can set this to be 70 and try to find a solution.
However, for your purposes, it might be better to just start with 70 and work backwards. When you get close to 4, round the result you get to find the closest. That is:
$\frac{70 + 2}{2} = 36$
$\frac{36 + 2}{2} = 19$
$\frac{19 + 2}{2} = 10.5$
$\frac{10.5 + 2}{2} = 6.25$
$\frac{6.24 + 2}{2} = 4.125$
$\frac{4.125 + 2}{2} = 3.0625$
This number is too small, so we pick 4.125 and round it to 4. So picking 4 is pretty good:
$a_5[4] = 2^5 (4) - 2^{5+1} + 2 = 64$
The final choice depends on how much you care about the final number being close to 70, and the initial value being close to 4. If you don't mind the initial value being large, 19 is pretty good.