General Formula for a sequence with indices increasing in the order $(2 * i)$, where i = 0,1,2,3...

29 Views Asked by At

I have generated a sequence which looks really simple : $f(n) = 0, 1, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 15 ....n$

The indices are having the same values in the order of $(2*i)$ where $i = 0,1,2,3...$

If possible, please help me generate it's formula.

Thank you

1

There are 1 best solutions below

1
On BEST ANSWER

Assuming your function is f(1)=0, f(2)=f(3)=1, f(4)=f(5)=f(6)=f(7)=3,...

So the formula could be $f(n)=2^{\lfloor\log_2(n)\rfloor}-1$ where $\lfloor x\rfloor$ means the largest integer no more than x.