Alternating bit smearing Introduction

This challenge requires you to set the trailing zeros of an integers binary representation to 010101…, this is best explained with an example:

Given the integer 400, the first step is to convert it to binary:

110010000


As we can see the fifth bit is the least significant 1 bit, so starting from there we replace the lower zeros by 0101:

110010101


Finally we convert that back to decimal: 405

Challenge

Given a positive integer return/output the corresponding resulting value of the above defined process.

Rules


This sequence is only defined for integers with at least one 1 bit, so the input will always be ≥ 1
You may take input as a string, list of digits (decimal) instead
You don't have to handle invalid inputs


Testcases

Here are some more testcases with the intermediary steps (you don't have to print/return these):

In -&gt; … -&gt; … -&gt; Out
1 -&gt; 1 -&gt; 1 -&gt; 1
2 -&gt; 10 -&gt; 10 -&gt; 2
3 -&gt; 11 -&gt; 11 -&gt; 3
4 -&gt; 100 -&gt; 101 -&gt; 5
24 -&gt; 11000 -&gt; 11010 -&gt; 26
29 -&gt; 11101 -&gt; 11101 -&gt; 29
32 -&gt; 100000 -&gt; 101010 -&gt; 42
192 -&gt; 11000000 -&gt; 11010101 -&gt; 213
400 -&gt; 110010000 -&gt; 110010101 -&gt; 405
298 -&gt; 100101010 -&gt; 100101010 -&gt; 298
Python 3, 20 bytes



lambda n:(n&amp;-n)//3+n


Try it online!

Explanation

Take 192 as an example. Its binary form is 11000000, and we need to convert it to 11010101.

We note that we need to add 10101 to the number. This is a geometric series (4^0 + 4^1 + 4^2), which has a closed form as (4^3-1)/(4-1). This is the same as 4^3//3 where // denotes integer division.

If it were 101010, then it would still be a geometric series (2×4^0 + 2×4^1 + 2×4^2), which is 2×4^3//3 for the reasons above.

Anyway, 4^3 and 2×4^3 would just be the least significant bit, which we obtain by n&amp;-n:

We notice that the complement of n is 00111111. If we add one, it becomes 01000000, and it only overlaps with n=11000000 at the least significant digit. Note that "complement and add one" is just negation.