Is there a closed form to this series? Here is the series in question,
1 + 2 + 1 + 4 +
1 + 2 + 1 + 8 +
1 + 2 + 1 + 4 +
1 + 2 + 1 + 16 +
1 + 2 + 1 + 4 +
1 + 2 + 1 + 8 +
1 + 2 + 1 + 4 +
1 + 2 + 1 + 32 + ...

so for example, given n = 4, the series sum is 1 + 2 + 1 + 4 = 8
I created this series inspired by the game 2048,
and I've been trying to find the closed-form with respect to n for a few hours to no avail.
Does there exist a closed-form? What's the name of this type of series?
 A: There's a number of ways to approach this problem. Let me give you an idea of two ways to investigate this sort of thing. For this post, let $a(n)$ be the $n^{th}$ term of the sequence and $b(n)$ be the sum of the first $n$ terms of $a$. I doubt there's anything that might ordinarily be called a closed form, but you can certainly do better than just summing the terms.

Way 1: Look it up!
This is exactly the kind of question that should lead a mathematician to search on OEIS (the online encyclopedia of integer sequences) - if we type in the original sequence as a search query, we can find a page here regarding the sequence - described as "Highest power of $2$ dividing $n$." This is not super useful on its own - although, as we will see, the formal description of the sequence given in its title is useful - but there are a lot of comments beneath that might often be of use to this sort of question. In fact, the comments even list the sequence of partial sums of the original sequence - exactly what you are asking about (though you could surely also find this by calculating the first few partial sums and searching for them).
In the comments there, we find out a pair of recurrence relations for $b$:
$$b(2n)=2b(n)+n$$
$$b(2n+1)=2b(n)+n+1$$
which gives an extremely efficient way of computing it - for instance, the sum of the first $9$ terms is:
\begin{align*}b(9)&=b(2\cdot 4 + 1)\\&=2b(4)+4+1\\&=2b(2\cdot 2)+5\\&=2(2b(2)+2)+5\\&=4b(2\cdot 1)+9\\&=4(2b(1)+1)+9\\&=8b(1)+13\\&=21\end{align*}
where we note on the last step that $b(1)=1$. The trick here is that we can always rewrite whatever is inside $b$ as either $2n$ or $2n+1$, halving its size at each step - and you can check that this really does equal $1+2+1+4+1+2+1+8+1$
While you won't find justification of this on OEIS, knowing the answer makes finding justification much easier: note that $a(2n)=2a(n)$, so the sum of the terms of $a$ at positions $2,4,\ldots,2n$ is twice the sum of the terms at $1,2,\ldots,n$ (which is $b(n)$) - hence is $2b(n)$. The terms at the odd positions are all $1$ - and there are $n$ or $n+1$ of them below $2n$ or $2n+1$ respectively.

Way 2: Try to express it in terms of something simpler.
Another way to look at this is to note that it's "mostly" periodic, with a few exceptions - or, even more formally, that you can look at it as "mostly $1$, with some $2$'s added, and then some $4$'s added on top of $2$'s and so on...". More formally, let's consider an array where, on the first row, we write all ones. Then, we start a new row, every other entry of which is $1$. If we sum those rows, we'd get $1,2,1,2,1,2,\ldots$. To correct this, we add a third row, every fourth entry of which is $2$ - and if we add that on we get $1,2,1,4,1,2,1,4,\ldots$ - we then continue adding a $4$ every $8$ columns to fix it further - then an $8$ every $16$ columns, a $16$ every $32$ columns, and so on until we've generated enough of our sequence:
$$\begin{array}\\
1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\
0 & 1 & 0 & 1 & 0 & 1 & 0 & 1\\
0 & 0 & 0 & 2 & 0 & 0 & 0 & 2\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 4 \end{array}$$
See how the sums of columns here are the entries of $a$. However, the sum of $n$ terms of any row is easy to figure out - clearly, the sum of $n$ terms of the first row is $n$. The second row has $\lfloor n/2\rfloor$ non-zero terms (where we use the floor function which rounds down its argument to the next integer) - each of which is $1$, so contributes $\lfloor n/2\rfloor$ in total. Then, the next row has $\lfloor n/4\rfloor$ non-zero terms, which are each $2$, so which contributes $2\lfloor n/4\rfloor$ to the sum. Continuing analogously, we will find that the sum of the first $n$ terms of the original sequence - which is the sum of the sums of the rows is:
$$n + \sum_{k=1}^{\infty}2^{k-1}\left\lfloor\frac{n}{2^k}\right\rfloor$$
where you only need to take this sum up to the last $k$ so that $2^k \leq n$, since the remaining terms after that are all zero.

Addendum: It might be worth noting that this function is pretty easy to describe on the large scale - the sum of the first $2^n-1$ terms is $n2^{n-1}$, which can be seen inductively by noting that the terms $1$ through $2^n-1$ are the same as those from $2^n+1$ to $2^{n+1}-1$ and the term at $2^n$ is just $2^n$ - and it actually looks more and more like a smooth curve the more you zoom out (though, note that the slope of the line that it looks like changes) - for instance, even the first 511 partial sums look pretty linear:

There's some small scale variation, but the function acts basically like $\frac{1}2 n\log_2(n)$ - here's that function overlaid on the prior plot:

Some more analysis can give that the deviations from this curve are actually quite small - their ratio tends to $1$ - but there's probably not a lot of hope for a much better representation since the deviations have some fractal nature. You could likely come up with some way to do this involving writing $n$ in binary and doing something weird to the bits - but that's largely just another way to encode the sorts of sums and recurrences that appear with this sort of sequence.
A: The $k$-th term is $\gcd(k,2^k)$, so the sum up to $n$ is $$\sum_{k=1}^n \gcd(k,2^k)$$
It can also be calculated as $$n+\sum _{k=1}^n 2^{k-1} \left\lfloor \frac{n}{2^k}\right\rfloor$$
No closed form is known for the sum, i think probably there isn't one.
