Print the Golfican sequence
The Golfican sequence is a sequence of integers, \$u\$, defined as follows:
- If \$n\$ is a power of \$2\$, then \$u_n=\log_2n+1\$.
- If \$n\$ in not a power of \$2\$, then \$u_n=u_p\$, where \$p\$ is the number of numbers from \$1\$ to \$n\$ inclusive which are not powers of \$2\$.
So, the first numbers in this sequence are \$1,2,1,3,2,1,3,4\$ and so on. It is equivalent to the sequence of numbers returned by the following JavaScript generator function:
function* golfican() {
var g = golfican();
var n = 0;
while (true) {
yield n + 1;
for (var i = 0; i < 2 ** n - 1; i++)
yield g.next().value;
n++;
}
}
Your job is to write a program which takes a number, \$x\$, as input, and outputs \$u_x\$. This is code-golf, so the shortest program in bytes wins.
I couldn't find a corresponding OEIS sequence for this. Thoughts? Should the sample program be included?