[Question]
  [
A bit floats from the [LSB](https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit) to the [MSB](https://en.wikipedia.org/wiki/Bit_numbering#Most_significant_bit) moving one position each time until it floats to the *top* of the container:
```
0000
0001
0010
0100
1000
```
Once one bit floats to the top, another bit begins its journey and it stops when it meets other bit:
```
1001
1010
1100
```
This happens until the container is filled with bits:
```
1101
1110
1111
```
### Challenge
Given an integer number, output the "*Bit floating sequence*" for a container of that number of bits.
* Each term of the sequence can be separated by any separator of your choice.
* **Edit**: Sequence must be shown as decimal integer numbers, starting by the first therm: `0`.
* The container size sould be greater than zero and up to the number of bits of the bigest integer suported by the language of your choice. You can assume that the input always match this requirement.
### Examples
Only the numeric sequence is required, binary representation is shown as example:
* For **1**: `0 1`
```
0 -> 0
1 -> 1
```
* For **3**: `0 1 2 4 5 6 7`
```
000 -> 0
001 -> 1
010 -> 2
100 -> 4
101 -> 5
110 -> 6
111 -> 7
```
* For **4**: `0 1 2 4 8 9 10 12 13 14 15`
```
0000 -> 0
0001 -> 1
0010 -> 2
0100 -> 4
1000 -> 8
1001 -> 9
1010 -> 10
1100 -> 12
1101 -> 13
1110 -> 14
1111 -> 15
```
* For **8**: `0 1 2 4 8 16 32 64 128 129 130 132 136 144 160 192 193 194 196 200 208 224 225 226 228 232 240 241 242 244 248 249 250 252 253 254 255`
```
00000000 -> 0
00000001 -> 1
00000010 -> 2
00000100 -> 4
00001000 -> 8
…
…
…
11111000 -> 248
11111001 -> 249
11111010 -> 250
11111100 -> 252
11111101 -> 253
11111110 -> 254
11111111 -> 255
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes
```
LRL˜Íoî.¥ï
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fJ8jn9JzDvfmH1@kdWnp4/f//JgA "05AB1E – Try It Online")
```
L                 # range [1..input]
 R                # reversed
  L               # convert each to a range: [[1..input], [1..input-1], ..., [1]]
   ˜              # flatten
    Í             # subtract 2 from each
     o            # 2**each
      î           # round up (returns a float)
       ï          # convert to integer
        .¥        # undelta
```
[Answer]
# [Python 2](https://docs.python.org/2/), 45 bytes
```
y=n=2**input()
while y:print n-y;y=y&y-1or~-y
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v9I2z9ZISyszr6C0REOTqzwjMydVodKqoCgzr0QhT7fSutK2Uq1S1zC/qE638v9/UwA "Python 2 – Try It Online")
It turns out shorter to generate `2**n` minus each term in the sequence for input `n`. If we look at their binary expansion, below for `n=5`, we see a nice pattern of triangles of 1's in the binary expansions.
```
100000  32
011111  31
011110  30
011100  28
011000  24
010000  16
001111  15
001110  14
001100  12
001000  8
000111  7
000110  6
000100  4
000011  3
000010  2
000001  1
```
Each number is obtained from the previous one by removing the rightmost one in the binary expansion, except if that would make the number 0, we subtract 1 instead, creating a new block of 1's that starts a new smaller triangle. This is implemented as `y=y&y-1or~-y`, where `y&y-1` is a bit trick to remove the rightmost 1, and `or~-y` gives `y-1` instead if that value was 0.
**[Python 2](https://docs.python.org/2/), 49 bytes**
```
def f(n,x=0):1%n;print x;f(n-x%2,x+(x%2**n or 1))
```
[Try it online!](https://tio.run/##K6gsycjPM/r/PyU1TSFNI0@nwtZA08pQNc@6oCgzr0ShwhooqFuhaqRToa0BpLS08hTyixQMNTX/p2mYav4HAA "Python 2 – Try It Online")
A function that prints, terminating with error. The more nice program below turned out longer.
**51 bytes**
```
n=input()
x=0
while n:n-=x%2;print x;x+=x%2**n or 1
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P882M6@gtERDk6vC1oCrPCMzJ1UhzypP17ZC1ci6oCgzr0ShwrpCG8TV0spTyC9SMPz/3xQA "Python 2 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage/wiki), ~~11~~ 10 [bytes](https://github.com/DennisMitchell/jellylanguage/wiki/Code-page)
```
RUḶ’F2*ĊÄŻ
```
Port of [*@Grimy*'s 05AB1E answer](https://codegolf.stackexchange.com/a/191392/52210), so make sure to upvote him!  
-1 byte thanks to *@Grimy*.
[Try it online.](https://tio.run/##y0rNyan8/z8o9OGObY8aZroZaR3pOtxydPf///9NAA)
**Explanation:**
```
R           # Create a list in the range [1, (implicit) argument]
 U          # Reverse it to [argument, 1]
  Ḷ         # Create an inner list in the range [0, N) for each value N in this list
   ’        # Decrease each by 1
    F       # Flatten the list of lists
     2*     # Take 2 to the power each
       Ċ    # Ceil
        Ä   # Undelta (cumulative sum) the list
         Ż  # And add a leading 0
            # (after which the result is output implicitly)
```
[Answer]
# Perl 5 (`-n`), ~~41~~ 40 bytes
-1 byte thanls to Xcali
```
map{/01.*1/||say oct}glob"0b"."{0,1}"x$_
```
[TIO](https://tio.run/##K0gtyjH9/z83saBa38BQT8tQv6amOLFSIT@5pDY9Jz9JySBJSU@p2kDHsFapQiX@/3@Tf/kFJZn5ecX/dfP@6/qa6hkYAgA)
* `"{0,1}"x$_` : the string `"{0,1}"` repeated n times
* `"0b".` : concatenate to `"0b"`
* `glob` : glob expansion (cartesian product)
* `map{`...`}` : for each element
* `/01.*1/||` : to skip when `01` followed by something then `1`
* `say oct` : to convert to decimal and say
[Answer]
# JavaScript (ES6), 43 bytes
When in doubt, use [xnor's method](https://codegolf.stackexchange.com/a/191424/58563).
```
n=>(g=x=>x?[n-x,...g(x&--x||x)]:[])(n=1<<n)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/P1k4j3bbC1q7CPjpPt0JHT08vXaNCTVe3oqamQjPWKjpWUyPP1tDGJk/zf3J@XnF@TqpeTn66RpqGoaZeVn5mnoa6joK6piYXqqQxPkkTfJIWKJL/AQ "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), ~~59 57 55~~ 52 bytes
```
f=(n,x=0)=>x>>n?[]:[x,...f(n,x+=x+(x&=-x)>>n|!x||x)]
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zVYjT6fC1kDT1q7Czi7PPjrWKrpCR09PLw0krm1boa1RoWarW6EJlKxRrKipqdCM/Z@cn1ecn5Oql5OfrpGmYaipl5WfmaehrqOgrqnJhSppjE/SBJ@kBYrkfwA "JavaScript (Node.js) – Try It Online")
### How?
We define \$p(x)\$ as the highest power of \$2\$ dividing \$x\$, with \$p(0)=0\$ by convention.
This function can be implemented with a simple bitwise AND of \$x\$ and \$-x\$ to isolate the lowest bit set to \$1\$ in \$x\$. For instance:
$$p(52)=52 \operatorname{AND}-52=4$$
Using \$p\$, the sequence \$a\_n\$ can be defined as \$a\_n(0)=0\$ and:
$$a\_n(k+1)=\cases{
a\_n(k)+p(a\_n(k)), & \text{if $p(a\_n(k))\neq0$ and $a\_n(k)+p(a\_n(k))<2^n$}\\
a\_n(k)+1, & \text{otherwise}
}$$
### Commented
```
f = (                   // f is a recursive function taking:
  n,                    //   n = input
  x = 0                 //   x = current term of the sequence
) =>                    //
  x >> n ?              // if x is greater than or equal to 2**n:
    []                  //   stop recursion
  :                     // else:
    [                   //   update the sequence:
      x,                //     append the current term to the sequence
      ...f(             //     do a recursive call:
        n,              //       pass n unchanged
        x +=            //       update x:
          x + (x &= -x) //         given x' = lowest bit of x set to 1:
          >> n          //         if x + x' is greater than or equal to 2**n
          | !x          //         or x' is equal to 0: add 1 to x
          || x          //         otherwise, add x' to x
      )                 //     end of recursive call
    ]                   //   end of sequence update
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~95~~ 76 bytes
```
n=input()
a=0
print 0
while n:
 for j in range(n):print a+2**j
 n-=1;a+=2**n
```
[Try it online!](https://tio.run/##Lc1LCgIxEATQfZ2iyWo@CJPoQkb6MGFsnQzSCSGinj7Gz7Ko4lV6lTWqq0s8CxtjqnLQdC9dD88TUg5aaMJjDTchnUGXmGmjoJS9XqXTfv5t/OiGYQPpju3Jj9yS1m@FxuIv2CbIUxb6/FULhz0OOL4B "Python 2 – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 43 bytes
```
{0 x$_,{say :2($_);S/(0)1|0$/1$0/}...1 x$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/2kChQiVep7o4sVLBykhDJV7TOlhfw0DTsMZARd9QxUC/Vk9PzxCkpvY/SE2agsV/AA "Perl 6 – Try It Online")
Anonymous code block that takes a number and outputs the sequence separated by newlines. This works by starting with 0 repeated n times then replacing either `01` with `10` or the last `0` with a `1` until the number is just ones.
Or 40 bytes, using [Nahuel Fouilleul's approach](https://codegolf.stackexchange.com/a/191383/76162)
```
{grep /010*1/|{say :2($_)},[X~] ^2 xx$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/Or0otUBB38DQQMtQv6a6OLFSwcpIQyVes1YnOqIuViHOSKGiQiW@9n@agsV/AA "Perl 6 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 60 bytes
```
f=lambda i,n=0,b=1:[n][i:]or[n]+f(i-1/b,n^b+b/2,b>>i or 2*b)
```
[Try it online!](https://tio.run/##RYzBCsIwEETv@Yq9tbGrbaMFCaQ/UipkkeCCTUoIBRG/PaZevL1h3sz6So/gVc7OPO1CdwuM3nRIpteTnyfWc4gFGlfzsW8J/Y0aahXSODKECOpAMrsCDOyhR1AIZ4QLwlULgDWyT@UTyl4K8Yti17ddd/Ug/1b11t1An@pU@sWmepP5Cw "Python 2 – Try It Online")
---
# [Python 3](https://docs.python.org/3/), 76 bytes
```
f=lambda n:[0][n:]or[0]+[2**i for i in range(n-1)]+[x|1<<n-1for x in f(n-1)]
```
[Try it online!](https://tio.run/##PcpBCoMwEEbhvaf4l8ZOwWgXEvQkwUXEph1oJxJcWPDuMVJw9@B7y299B2lT8sPHfafZQYytRytmDDHHzTZVxfAhgsGC6OT1LOWuVaZt132f@9TtVP@XdO2a0BBawoPQmQJYIstaMuWVlUoH "Python 3 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 67 bytes
```
n=0
i=2**input()-1
while n<=i:print n;d=n&(~-n^i)or 1;n+=n+d>i or d
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P8/WgCvT1khLKzOvoLREQ1PXkKs8IzMnVSHPxjbTqqAoM69EIc86xTZPTaNONy8uUzO/SMHQOk/bNk87xS5TAchL@f/fAgA "Python 2 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 62 bytes
```
def f(n,c=0):
 while c<2**n:yield c;r=c&-c;c+=c+r>>n or r or 1
```
[Try it online!](https://tio.run/##ZZDBasMwEETv/orFh2InKtiy7MZOHSilh576AWkoQZGJIchGVkhC6Le7O26gpdVh0b6ZHYntL37f2Wwcd6ahJrJC10lcBXTatwdD@lHOZra6tOawI710tb6710s9r/XcrVaWOkcOJR29GfyH3g5moJrWQZQKWieC0k0sgkjeGkF8yyaU/UZKUC6oEPQwaeqPthBUcgvEIOXRlGmaT@bFf3PKSRl3BVwSQGI@gy2bEgpEQC3ASrASsSVYyapMEhSelVKh5CgQkCeRIhUsCg@rqYVPQVX8msyh5hDyDAVqzl8ONkHQ8MpaQebcU2vpZ3W8dz7d0WOHsyZq481EtsNgnP8WaowJasJ3@2r7o69guLaf7/bt6G/9lZ0MXs690d7sKrryDINwSutda30UPnfOsUxPdjgZF8bjFw "Python 3 – Try It Online")
The idea is more or less the same as [@Arnauld's solution](https://codegolf.stackexchange.com/a/191388/88506).
Another 65-byte solution:
```
lambda n:g(2**n-1)
g=lambda c:[0][c:]or g(c-((c&-c)//2 or 1))+[c]
```
[Try it online!](https://tio.run/##ZZDBSsQwEIbveYqhB0nWLNukad0WehDx4MkH6Bap2XYtaFraLK4sPnudiQuK5jBkvv@fP2HGD/8yuGTpyt3y2rw97xtwxYHr1cqtlWCH8gJtUcV1ZYt6mODA7Zpze7W2YrPRgEQJcV3ZevHt7J9sM7czlFAxriRUsQRVC8m4vjQS8JYElPxGRkIqIZNwEzTzR9tKyLElhEDhqEKq0mDe/jcrTEqwy8ilCWiaT8iWhISMIkjNiOXEcorNieWo6jimgrNaGyopFRIoT1OKNmQx9LAJLfkMqQZf0ympKQlpQoXUFL/MasY6XFwvoT2N0Dv4WV3BAM9w9LTDVcd7UQfSzHM7@W@hpDEJXbRzD248@oIM5/5z5x6P/tKf0Yng/jS21rf7As44gyAKaePUO8@ju2GaUIZbN7@3UySWLw "Python 3 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
⁼þ‘ṚÄUo€ƊẎQḄ
```
[Try it online!](https://tio.run/##ASYA2f9qZWxsef//4oG8w77igJjhuZrDhFVv4oKsxorhuo5R4biE////OA "Jelly – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~13~~ 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Tsãʒ1ÛSO2‹}C{
```
-1 byte thanks to *@Grimy* (also take a look at his shorter approach here).
[Try it online](https://tio.run/##yy9OTMpM/f8/pPjw4lOTDA/PDvZXrHWu/v/fBAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/kOLDi09NMjw8O9hfsda5@r/O/2hDHWMdEx2LWAA).
**Explanation:**
```
T             # Push 10
 sã           # Swap to get the (implicit) input, and get the cartesian product with "10"
   ʒ          # Filter it by:
    1Û        #  Remove leading 1s
      SO      #  Get the sum of the remaining digits
        !     #  Check that the sum is either 0 or 1 by taking the factorial
              #  (NOTE: Only 1 is truthy in 05AB1E)
         }C   # After the filter: convert all remaining strings from binary to integer
           {  # And sort (reverse) them
              # (after which the result is output implicitly)
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 26 bytes
```
.+
*0
L$w`.(.*)
$.`*1$'1$1
```
[Try it online!](https://tio.run/##K0otycxLNPz/X0@bS8uAy0elPEFPQ09Lk0tFL0HLUEXdUAUoZwEA "Retina – Try It Online") Outputs in binary. If that's not acceptable, then for 39 bytes:
```
.+
*0
L$w`.(.*)
$.`*1$'1$1
+`10
011
%`1
```
[Try it online!](https://tio.run/##K0otycxLNPz/X0@bS8uAy0elPEFPQ09Lk0tFL0HLUEXdUMWQSzvB0IDLwNCQSzUBqNACAA "Retina – Try It Online") Explanation:
```
.+
*0
```
Convert the input into a string of `n` zeros.
```
L$w`.(.*)
```
Match all possible non-empty substrings.
```
$.`*1$'1$1
```
For each substring, output: the prefix with `0`s changed to `1`s; the suffix; the match with the initial `0` changed to `1`.
```
+`10
011
%`1
```
Convert from binary to decimal.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 27 bytes
```
1;0|⟦₅;2z^₍ᵐLtT&-₁↰+ᵐ↙T,L,0
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Om5pT86vKHOxeV1z7cOuFRx/KHu3Y83NUJ4vw3tDaoeTR/2aOmVmujqrhHTb1AQZ@SEDXdR02NQL3aIA1tM0N0fHQM/v@PNtQx1jHRsYgFAA "Brachylog – Try It Online")
Outputs out of order and with duplicates. If that's not okay, tack `do` onto the end.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 19 bytes
```
Ｉ⮌Ｅ⊕θＥι⁺⁻Ｘ²ＩθＸ²ιＸ²λ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEIyi1LLWoOFXDN7FAwzMvuSg1NzWvJDVFo1BTRwEklqmjEJBTWqzhm5kHJAPyy1OLNIx0FMB6CzWBiuBCmSi8HE0IsP7/3@K/blkOAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
    θ               Input
   ⊕                Incremented
  Ｅ                 Map over implicit range
      ι             Outer index
     Ｅ              Map over implicit range
           Ｉθ       Input cast to integer
               ι    Outer index
                  λ Inner index
         Ｘ²  Ｘ² Ｘ²  Power of 2
       ⁺⁻           Subtract and add
 ⮌                  Reverse outer list
Ｉ                   Cast to string
                    Implicitly print
```
[Answer]
# [Perl 5](https://www.perl.org/), 40 bytes
```
map{say$-;$-+=2**$_}0,0..$_-2;$_--&&redo
```
[Try it online!](https://tio.run/##K0gtyjH9/z83saC6OLFSRddaRVfb1khLSyW@1kDHQE9PJV7XyBpI6KqpFaWm5P//b/Evv6AkMz@v@L@ur6megaHBf908AA "Perl 5 – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 24 bytes
```
.+
*0
/0/+<0`(0)1|0$
1$1
```
Outputs in binary. Input should have a trailing newline.
Attempt at explanation:
```
.+              #match the entire input
*0              #replace it with that many zeroes
/0/+<0`(0)1|0$  #while the string has a 0, substitute the first match and output
1$1             #if 01 is present in the string, replace it with 10, else replace the last character with $
```
I tried to avoid the 3 bytes long `/0/` regex option by rearranging the options, but couldn't.
[Try it online!](https://tio.run/##K0otycxLNPz/X0@bS8uAS99AX9vGIEHDQNOwxkCFy1AFKGPCBQA "Retina – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), 73 bytes
```
o,j,y;f(x){for(o=j=0;printf("%d ",o),x;o+=y+!y,y+=y+!y)j=!j?y=0,--x:--j;}
```
[Try it online!](https://tio.run/##JcvBCsIwDADQe7@iGwgJS6EnD4bgt4xpZUUbKRMaxr69Cp7e6S1hec7l0btSJuMEDfekFVSyRH7XtWwJxtPNj6RIjXUSmwYj@4tZhnw1iRRCu4SQ@ei/4l/zWgD97hKckV29b59afGR39C8 "C (clang) – Try It Online")
```
for(o=j=0;printf("%d ",o),x;  o+=y+!y, y+=y+!y) 
// adds 1, 1+1=>2 , 2+2=> 4 .... sequence
 j=!j?y=0,--x:--j; 
// uses ternary instead of nested loop to decrement 'x' when 'j' go to 0
```
[Answer]
# k4, ~~28~~ 24 bytes
```
0,+\"j"$2 xexp,/-1+|,\!:
```
@Grimy's approach ported to k4
edit: -4 thanks to ngn!
]