Question: I have a sequence as follows:

$$1, 2, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32 ...$$

What will be the closed form of the above sequence for the nth term?

I clearly see the pattern of $2^x$ getting repeated $2^{x-1}$ times. But I am getting confused in finding the closed form of this sequence.

EDIT:

Thanks @Arthur for providing the closed form. Now to extend the questiona bit further, **what would be the sum upto nth term given the closed form?**.

Looking at the closed form, it seems like that the sum would be of the order of $N^2$, but not able to find the exact value. I would like to see how much difference would it make because of the "ceiling" function.

Answer: 
If we start indexing at $n = 1$, we get $$a\_n = 2^{\lceil \log\_2 n\rceil}$$where $\lceil - \rceil$ is the ceiling function.
If we start indexing at $n=1$, the sum I believe is this:

$$s\_n=(n-2^{\lfloor\log\_2 n\rfloor})\cdot a\_n+2\cdot\frac{4^{\lfloor\log\_2 n\rfloor}-1}{3}+1$$