# What is general term of the sequence : $1, 2, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32 …$?

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.

• I think you went wrong while writing the sequence here. Kindly reconsider it. – Abhinav Dhawan Sep 7 '17 at 12:43
• Then $2=2^1$ should repeated $2^0=1$-times, not $2$-times. – Dietrich Burde Sep 7 '17 at 12:46
• And 1 also does not follow the pattern you wrote. Have you wrote it incorrect by mistake or is this sequence correct? – Abhinav Dhawan Sep 7 '17 at 12:49
• My bad. Sorry. Updated the sequence now. 2 should be repeated only once. – user3243499 Sep 7 '17 at 12:52
• I do not understand very well to the notion of "closed-form". Can that be also a recursive expression? – TStancek Sep 7 '17 at 13:06

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$$