[Question]
  [
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$10110001\_{(2)}\$:
* \$ 10110001\_{(2)}=177 \$
* \$ 01100011\_{(2)}=99 \$
* \$ 11000110\_{(2)}=198 \$
* \$ 10001101\_{(2)}=141 \$
* \$ 00011011\_{(2)}=27 \$
* \$ 00110110\_{(2)}=54 \$
* \$ 01101100\_{(2)}=108 \$
* \$ 11011000\_{(2)}=216 \$
27 is the smallest rotating result. So we output 27 for 177.
## Input / Output
You may choose one of the following behaviors:
* Input a positive integer \$n\$. Output its smallest bit rotation as defined above.
* Input a positive integer \$n\$. Output smallest bit rotation for numbers \$1\dots n\$.
* Input nothing, output this infinity sequence.
Due to definition of this sequence. You are not allowed to consider it as 0-indexed, and output smallest bit rotate for \$n-1\$, \$n+1\$ if you choose the first option. However, if you choose the second or the third option, you may optionally include 0 to this sequence, and smallest bit rotation for \$0\$ is defined as \$0\$. In all other cases, handling \$0\$ as an input is not a required behavior.
## Test cases
So, here are smallest bit rotate for numbers \$1\dots 100\$:
```
 1  1  3  1  3  3  7  1  3  5
 7  3  7  7 15  1  3  5  7  5
11 11 15  3  7 11 15  7 15 15
31  1  3  5  7  9 11 13 15  5
13 21 23 11 27 23 31  3  7 11
15 13 23 27 31  7 15 23 31 15
31 31 63  1  3  5  7  9 11 13
15  9 19 21 23 19 27 29 31  5
13 21 29 21 43 43 47 11 27 43
55 23 55 47 63  3  7 11 15 19
```
## Notes
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") as usual.
* This is [A163381](https://oeis.org/A163381).
* The largest bit rotation is [A163380](https://oeis.org/A163380). [A233569](https://oeis.org/A233569) is similar but different. (The first different item is the 37th).
  
[Answer]
# x86-64 machine code, ~~18~~ 16 bytes
```
0F BD D7 0F 43 C7 0F B3 D7 D1 D7 39 F8 75 F4 C3
```
[Try it online!](https://tio.run/##XVCxTsMwEJ3trziCKtlNWrUUMbRNF2YWJiRgcBwnMXKcykmLo6q/Tji3BRWWO917z/feWU5KKYfhVltpdrmCddvluplWG/oHMjr7jzlty4BRbTsoWKiCr6hoa2DwHDE6LU2TCQMFLZYkax2o3CdYNHVLIutmbyUocYFI1gWBDpOnxElznuYUpdsr3YdV4FCgOsojQMOTfy20PUdwpUxAVsLBeIzDntMDJYHxkMIsgT60FSWflTYKWBx7WKewmHNKyBZv6goWjTRMNjDSbzZKAI0L5jk6/fJv9knISmMS2eRqGQXOX/bmDRx@dDCa3b3gij5lbGdbXVqVn7KNecFffRy/89URLkl6uMEN/nFx7QQMs2R9p1p@DhNIvH3nbHA70mH4koURZTtM6od7LPj/Kb5V5hs "C (gcc) – Try It Online")
Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes \$n\$ in EDI and returns its smallest bit rotation in EAX.
In assembly:
```
f:  bsr edx, edi    # Set EDX to the highest position of a 1 bit in n.
r:  cmovnc eax, edi # (EAX will hold the lowest rotation found so far.)
                    #  Set EAX to EDI if CF=0. The first iteration, CF=0 always:
                    #  the value of CF after BSR is officially undefined, but it is
                    #  consistently 0 (as this code needs) on at least some CPUs.
                    #  (To not rely on this, add CLC before this for +1 byte.)
                    #  On later iterations, CF=1 if EDI ≤ EAX (from the cmp).
    btr edi, edx    # Set the bit at position EDX in EDI to 0.
                    #  Set CF to the previous value of that bit.
    rcl edi, 1      # Rotate EDI and CF together left by 1,
                    #  putting the removed bit back in at the end.
    cmp eax, edi    # Compare EAX and EDI.
    jne r           # Jump back if they are not equal.
                    #  (Once a value repeats, all possible values have been seen.)
    ret             # Return.
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
bā._Cß
```
Input \$n\$; outputs the smallest bit rotation.
[Try it online](https://tio.run/##yy9OTMpM/f8/6UijXrzz4fn//xuamwMA) or [verify all test cases](https://tio.run/##yy9OTMpM/X@xydXPXknhUdskBSV7v/9JRxr14p0Pz/@v89/Q3BwA).
Both the \$[1,n]\$ list with an input \$n\$ and infinite list would be 2 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) longer with a leading `Lε` or `∞ε` respectively.  
[Try the infinite version online.](https://tio.run/##yy9OTMpM/f//Uce8c1uTjjTqxTsfnv//PwA)
**Explanation:**
```
b       # Convert the (implicit) input-integer to a binary-string
 ā      # Push a list in the range [1,length] (without popping the string)
  ._    # Map each integer v in the list to a v-times (left-)rotated version of the
        # binary-string
    C   # Convert each binary-string in the list back to an integer
     ß  # Pop and leave the minimum
        # (which is output implicitly as result)
```
[Answer]
# Excel, ~~81~~ ~~80~~ ~~71~~ 68 bytes
`=LET(a,DEC2BIN(n),b,LEN(a),c,SEQUENCE(b),MIN(BIN2DEC(MID(a&a,c,b))))`
Input ***n***
*With many thanks to @KevinCruijssen for the great suggestions and 11-byte improvement!*
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 73 bytes
It's not pretty, and it doesn't work on TIO. But it works in the program itself.
```
x=de2bi(k=input(''));for i=1:k,[ans,bi2de(circshift(x',i)')];end,min(ans)
```
[Try it online!](https://tio.run/##Dco7DoAgDADQq7jRJiwySjiJceAbGyIYQMPtq29@1Q/7RuZpQlSOIBsq9zNACESdalvIrFuWuy1dOlIhgqfm@0lpwBSSUOChYwnyogJ/QuYP "Octave – Try It Online")
```
x=de2bi(k=input(''));for i=1:k,[ans,bi2de(circshift(x',i)')];end,min(ans)
        k=input('')                   % Take input, k = 177
x=de2bi(k=input(''));                 % Convert input to binary, k = [1 0 0 0 1 1 0 1], 
                                      % x = 177
for i=1:k,[...];end                   % Do k times (177 times)
                                      % Shortest way to make something happen enough times
               circshift(x',i)')      % Transpose x to make a vertical vector
                                      % Shift it i times, and transpose it back
                                      % Must be transposed for circshift to work
         bi2de(circshift(x',i)')      % Convert to decimal
    [ans,bi2de(...)]                  % Concatenate into a long vector 'ans'
min(ans)                              % The minimum of this vector       
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jellylanguage/wiki/Code-page)
```
BṙRḄṂ
```
[Try it online!](https://tio.run/##y0rNyan8/9/p4c6ZQQ93tDzc2fT//39Dc3MA "Jelly – Try It Online")
#### Explanation
```
BṙRḄṂ  # Implicit input (n)
B      # Convert n into binary
 ṙ     # Rotate this string this many times:
  R    #  Each of the numbers in [1..n]
       # (this will generate some duplicates, but that's fine)
   Ḅ   # Convert each one back from binary
    Ṃ  # Get the minimum of this list
       # Implicit output
```
[Answer]
# [Python](https://www.python.org), 61 bytes
*-5 bytes thanks to `Shaggy` and -5 bytes thanks to `M Virts`.*
Takes a positive integer `n` as input. Outputs its smallest bit rotation in integer form.
```
lambda n:min(int((a:=f'{n:b}')[i:]+a[:i],2)for i in range(n))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3bXMSc5NSEhXyrHIz8zQy80o0NBKtbNPUq_OskmrVNaMzrWK1E6OtMmN1jDTT8osUMhUy8xSKEvPSUzXyNDUhhqwtKAJpTNMwNDeHiS1YAKEB)
[Answer]
# [J](http://jsoftware.com/), 16 bytes
```
[:<./2#.i.|."{#:
```
[Try it online!](https://tio.run/##y/r/P03B1koh2spGT99IWS9Tr0ZPqVrZ6n9qcka@gqEBCKkopCkZKNhZKWTqAbkGCv8B "J – Try It Online")
* `#:`: Convert \$n\$ to binary.
* `i.` `|.` `"` `{`: `i.` makes a list of the integers from 0 (inclusive) to \$n\$ (exclusive), then `|.` uses that to rotate the binary expansion of \$n\$, with its ranks being set (`"`) to the ranks of `{` so that it takes each integer as a separate rotation.
* `2` `#.`: Convert back from binary expansions to numbers.
* `[:` `<.` `/`: Take the minimum, using a 'cap' to do so monadically.
[Answer]
# [><> (Fish)](https://esolangs.org/wiki/Fish), 91 bytes
```
i0$1>:@$:@)?!v\
 ;n\^@+1$*2@ <r
$@:\?=@:$@:r-1/&~$?)@:&:
2+*2~v?:}:{%2:/.2b-%1:,
1$*2$/.38-
```
[Try it](https://mousetail.github.io/Fish/#eyJ0ZXh0IjoiaTAkMT46QCQ6QCk/IXZcXFxuIDtuXFxeQCsxJCoyQCA8clxuJEA6XFw/PUA6JEA6ci0xLyZ+JD8pQDomOlxuMisqMn52Pzp9OnslMjovLjJiLSUxOixcbjEkKjIkLy4zOC0iLCJpbnB1dCI6IjEwMCIsInN0YWNrIjoiIiwic3RhY2tfZm9ybWF0IjoibnVtYmVycyIsImlucHV0X2Zvcm1hdCI6Im51bWJlcnMifQ==)
Instead of counting how many iterations happened, which would be expensive, this exits if the current value equals the minimum value.
[![Diagram](https://i.stack.imgur.com/WYrgF.png)](https://i.stack.imgur.com/WYrgF.png)
[Answer]
# [R](https://www.r-project.org), ~~62~~ 59 bytes
*Edit: -3 bytes thanks to pajonk*
```
\(n,j=2^(0:(i=log2(n))))min(j%*%array(n%/%j%%2,2:3+i)[-1,])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMG24tzEnJzU4pL4pMyS-KL8ksSSzPw826WlJWm6FjetYzTydLJsjeI0DKw0Mm1z8tONNPI0gSA3M08jS1VLNbGoKLFSI09VXzVLVdVIx8jKWDtTM1rXUCdWE2qEcnFiQUFOpYahlaGBgQ5W26BKFyyA0AA)
Instead of iteratively rotating bits, we use them to fill a 2D array with one-too-many rows, with recycling, so that each column ends-up with the bits rotated (plus an extra useless row).  
We can then use matrix multiplication (`%*%` in R) with a vector of powers-of-2 to easily calculate the values encoded by each column, and output the minimum one.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 63 bytes
```
x=>'0b'+[...y=x.toString(2)].map(t=>y=y.slice(1)+t).sort()[0]-0
```
[Try it online!](https://tio.run/##DclBDsIgEADAux8pG9INNtEL0k/02PSACM0aZBsgprweneu87dcWl@moY@KX78H008yDeg5yRcRmTqy81ExpFxNs@LGHqGZupmGJ5Ly4gqyAhXMVsKptVF1fAmdBZJQmeky3u5aSCBynwtFj5F2EfwP0Hw "JavaScript (Node.js) – Try It Online")
`t` keeps being the needed digit
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 9 bytes
Anonymous tacit prefix function.
```
⌊/⍳⊥⍤⌽¨⊤¨
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn//1FPl/6j3s2PupY@6l3yqGfvoRWPupYcWvE/7VHbhEe9fY@6mh/1rnnUu@XQeuNHbRMf9U0NDnIGkiEensH/0w6tMDRQMDQASgONMDQwAAA "APL (Dyalog Extended) – Try It Online")
`⌊/` the smallest (lit. minimum-reduction) of
`⍳`…`¨⊤¨` for each integer in the range 1 through \$n\$, combined with the binary representation of \$n\$:
 …`⍤⌽` rotate that representation that integer steps left, and then:
  `⊥` convert back to a regular number
[Answer]
# [R](https://www.r-project.org), ~~80~~ ~~78~~ ~~75~~ 71 bytes
```
f=\(n,b=2^(0:log2(n)),x=n%/%b%%2)if(n)min(x%*%b,f(n-1,b,c(x[-1],x[1])))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGCpaUlaboWN93TbGM08nSSbI3iNAyscvLTjTTyNDV1KmzzVPVVk1RVjTQz04AiuZl5GhWqWqpJOkCerqFOkk6yRkW0rmGsTkW0YaympibUOP00DUNNLiBhDCbNzTW5chNLijIrNIoTCwpyKjUMrQwNDHTSNHUMDXR0QqDaYK4BAA)
Recursive function that in every iteration rotates the binary representation by one place and keeps track of the minimum value.
[Answer]
# [Fig](https://github.com/Seggan/Fig), \$18\log\_{256}(96)\approx\$ 14.816 bytes
```
[KeBtLbxGWbxO'J]xq
```
[Try it online!](https://fig.fly.dev/#WyJbS2VCdExieEdXYnhPJ0pdeHEiLCIxNzciXQ==)
Fig is missing a few important builtins, so this is longer than expected.
```
[KeBtLbxGWbxO'J]xq
          bx       # Get the binary form of this number
        GW         # Generate an infinite list from the binary
            O'     # Using the function...
              J]xq # Rotate by prepending the last element to the tailless list
     Lbx           # Length of the binary representation
    t              # Take that many items from the infinite list
  eB               # Convert each from binary
 K                 # Sort ascending
[                  # Take the first element (i.e. the minimum one)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~73~~ 61 bytes
```
s;l;r;f(n){for(l=r=log2(s=n);r--;s=s<n?s:n)n=n%2<<l|n/2;r=s;}
```
[Try it online!](https://tio.run/##jVJdb4MgFH3vr7hp0gRbTafMNg7ZHpb9irUPDcXOzGIDLjPr/OtzgGht1oeRHOCee@4H4bLgwFjbKlIQSTIkvHNWSlRQSYvyECFFhUdkEBBFVSqe1IPwBBWzKE2Lb7GMiKSKNG0uKjjucoE8OE9AL0Pw@sRZxfevW6BwDn0AAzw6DdYjO/at2dMaYXzttrw@w9AhvugH28UZ4PBGfOK02Onj7h5pLsKdL1p3dxz@zW@1uNNYv6vX6/u6Biv8j/rGTkb1E1c/cfnH/TndPXZYX/o1duz6MKfxrfCN/pOG2E9ipVAVsLednOuds3cuu7@abuqXaFMnzxrx1IexjacuWo8JIPPPudjzWofdEXdNQeVfvMxQPwEeLHtqPnAEFgur72emn5tK5@oSLSAkVy6lXRmqvGuWa3YYNhu5vQhOUksyNJ3tIXgEvc/URug3VT4of3i2opRvXdrG7pJXH1LoR02a9odlxe6g2uCzDYrjLw "C (gcc) – Try It Online")
*Saved a whopping 12 bytes thanks to [c--](https://codegolf.stackexchange.com/users/112488/c)!!!*
[Answer]
# [Python](https://www.python.org), 57 bytes
```
lambda n:int(min(h:=f"{n:b}",*[h:=h[1:]+k for k in h]),2)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3LXMSc5NSEhXyrDLzSjRyM_M0Mqxs05Sq86ySapV0tKKBvIxoQ6tY7WyFtPwihWyFzDyFjFhNHSNNqAEGIOFMkHBRYl56qoahjqGBgaZVQRHIvEydNI1MTZ3UvBRbJQUFXV0FBSWovgULIDQA)
### Old [Python](https://www.python.org), 58 bytes
```
lambda n:int(min([h:=f"{n:b}"]+[h:=h[1:]+k for k in h]),2)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3rXISc5NSEhXyrDLzSjRyM_M0ojOsbNOUqvOskmqVYrVBvIxoQ6tY7WyFtPwihWyFzDyFjFhNHSNNqAkGIOFMkHBRYl56qoahjqGBgaZVQRHIwEydNI1MTZ3UvBRbJQUFXV0FBSWovgULIDQA)
[Answer]
# [C (gcc)](https://gcc.gnu.org/) with `-lgmp`, ~~233~~ ~~231~~ 227 bytes
* -6 thanks to ceilingcat
As it uses the GMP library, the maximum integer that this function handles is quite large. Takes a number as a string to avoid overflowing native types.
```
#import<gmp.h>
f(s,v,w,x,y)char*s,*v;{mpz_t c,l;mpz_init_set_str(c,s,10);mpz_init(l);for(y=x=strlen(v=mpz_get_str(0,2,c));y--;mpz_cmp(c,l)>0?mpz_set(c,l):0)w=v[x-1],bcopy(v,v+1,x-1),*v=w,mpz_set_str(l,v,2);gmp_printf("%Zd",c);}
```
[Try it online!](https://tio.run/##ZU9bbsIwEPznFFYqJBs2VZwHJDWm9yhCiBoSLCUkilNDirh603WK@KlkW7ue2dkZ5RdKDcOLrpq67VZF1bye1pOcGrBwgSv0TJ327czAzIpb1XzvOqKgFK7SZ93tzBFv11IFBnjAngAtmcjrlvbyKhEvj2dqpQOLx0AAISjGRO/745CqGhQp2Tp4dy3qju1bwC7Sbq4@38KnqpueWrBzDvjB0JO8wIM9ipboOmQCU@yaVp@7nHrTj4OHi8R9wJ5Ue41Gan1g5DYhxGUjMyO9iMc8ycJFEiVptsyiMErjRbiIoyiNwmWWBGGaxh4Qu@HBVuCkE9NigpVLqWUgiF7xgAvSfHWGeh7720CIeTixQLwpeiF6PmdihJ4eDZFr4uTxMEGQPDLuTv8fyYwMfCf34Ufl5b4wg19i5l8 "C (gcc) – Try It Online")
Ungolfed:
```
#import<gmp.h>
f(s, // input value
  v, // bit representation of value
  w, // rotated bit
  x,y // bit string length and loop counter
  )char*s,*v; {
  mpz_t c,l; // current lowest value, test value
  mpz_init_set_str(c,s,10); // initialize variables
  mpz_init(l);
  for(
    y=x=strlen(v=mpz_get_str(0,2,c)); // initialize bit string
    y--;
    mpz_cmp(c,l)>0?mpz_set(c,l):0) { // adjust lowest value
    w=v[x-1]; // get rotated bit
    bcopy(v,v+1,x-1); // rotate
    *v=w; // put rotated bit at top
    mpz_set_str(l,v,2); // get test value
  }
  gmp_printf("%Zd",c);
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 76 bytes
```
i,o=bin(input())[2:],[]
for x in i:i=i[-1]+i[:-1];o+=[int(i,2)]
print min(o)
```
[Try it online!](https://tio.run/##DcwxDoAgEAXRnlNQQsACGhIMJ9nQWBh/4S4hmOjpkWpeNe0bl3CcE17KATbg9gxjLcVcPVV1StevBmtkFNAWqgPllV1cIfAw8NFW1fqyvtdB7JwhpR8 "Python 2 – Try It Online")
Python2 because it accepts integers directly as input (no int() required) and it saves a space on the print statement by not needing brackets.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 55 bytes
```
.+
$*
+r`\1(1+)
0$1
10
1
.
$&$'$`¶
1
10
+`01
110
O`
\G1
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRYtLuyghxlDDUFuTy0DFkMvQgMuQS49LRU1FXSXh0DYusIh2ggGQBjL8E7hi3A3//zc0NwcA "Retina 0.8.2 – Try It Online") Explanation:
```
.+
$*
```
Convert to unary.
```
+r`\1(1+)
0$1
10
1
```
Convert to mirrored binary i.e. LSB first, MSB last.
```
.
$&$'$`¶
```
Generate all of the rotations.
```
1
10
+`01
110
```
Convert each rotation back to unary.
```
O`
```
Sort.
```
\G1
```
Convert the shortest to decimal.
[Answer]
# [Factor](https://factorcode.org/), 43 bytes
```
[ >bin all-rotations [ bin> ] map infimum ]
```
[Try it online!](https://tio.run/##RYyxCsJADEB3vyIfYEu7KnQVFxdxKh3SktbAXe5MUtCvPysdHN978GacPGl53K@3ywki@rPOqEYKRq@VZCKr6e2KtkdFWcj@EbKS@ycri8Oiac0sC5wPh7ZpoG@P41B66EYWwBAqTY7OSQx62FwHw3bNwDJzXCMM5Udts4/AOOZAleMYqC5f "Factor – Try It Online")
```
>bin              ! convert input from decimal to a binary string
all-rotations     ! get every rotation as a sequence of strings
[ bin> ] map      ! convert each to decimal from binary
infimum           ! get the smallest one
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 16 bytes
```
&/2/'{1_x,*x}\2\
```
[Try it online!](https://ngn.codeberg.page/k#eJx9UX9rwjAQ/T+fIoMxdf6IlxhDm4+iMmvXarEa12ZQEffZl1xbmTACR7i89+5e2pfHb4yzwQ0+msl7c1/zNSE2vr2urj9VnFNKG701Rz3c5klR6kZfdTXa3Amp4iFQ6kr0pyvV95JQvLWYoiAfDCKeB8CSnarrUQueF/A8E6FEoArnBeVAufAwV74R8NjleYkS4UnP4OZW1e93tRT/urTz/hb1LhG6RLjrjz/yC4Glurcs/LxEN3c6eCmevhKikfvLgxWMX2A+1xNWbQhh5GDtpY4ZS81ntjdlPqttkh6zJj0k5302S82JfX1ntS3MuWZcKqE4q09JWTpsuivstDI28SwhNBxOMJpwMOFYwqGEIwkHEo4jHEYwil/tkZRF)
* `2\` convert (implicit) input to its binary representation
* `{1_x,*x}\` build a list of all rotations of the bits
* `2/'` convert each back to its decimal representation
* `&/` calculate, and (implicitly) return the minimum
[Answer]
# [Python 2.7](https://www.python.org/download/releases/2.7/), 73 bytes
```
x=bin(input())[2:]
print min([int(x[i:]+x[:i],2)for i in range(len(x))])
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `g`, ~~7~~ 6 bytes
```
ƛ?b$ǓB
```
[Try it online!](https://vyxal.pythonanywhere.com/#WyJnIiwiIiwixps/YiTHk0IiLCIiLCIxNzciXQ==)
* -1 thanks to a suggestion from Shaggy
#### Explanation
```
ƛ?b$ǓB  # Implicit input
ƛ       # Map over the range:
 ?b     #  Get the input in binary
   $Ǔ   #  Rotate ^ ^^ times
     B  #  Convert it back from binary
        # g flag gets the minimum of this list
        # Implicit output
```
Previous 7-byter:
```
b:ż¨VǓB  # Implicit input
b        # Convert the input to binary
 :ż      # Duplicate and push range(len(^))
   ¨V    # Map over each element in ^:
     Ǔ   #  Rotate ^^^ ^ places to the left
      B  # Convert each back from binary
         # g flag gets the minimum of this list
         # Implicit output
```
[Answer]
# JavaScript (ES6), 57 bytes
*-2 bytes thanks to [@l4m2](https://codegolf.stackexchange.com/users/76323/l4m2)*
```
n=>(m=g=q=>x--?g(q%2<<Math.log2(n,m=m<q?m:q)|q/2):m)(x=n)
```
[Try it online!](https://tio.run/##NYzNbsJADITvfQpfKmyFLJDeyBqegBPHisMqJCEou5tNFoT46asHp1UP1oztb@ZsrmYo@qaLqfPHcqx4dLxByzUH3tzSdFtj@My0/tmZeFJFe//K0M0tWx22dh3oGRYZrS3hjR2Nle@xLSM4YFjmIhpWy1@TsDiCxwfABBgBvg@5bP8RK5dVLqInUkyS/OEARnWX4YQVSg1YUtHvY9@4Gkl15riPpo@YEU1tL5nCu8G3pWp9jUadfeNwBrPp/xrf "JavaScript (Node.js) – Try It Online")
### Commented
```
n => (              // n = input
  m =               // m = minimum value, initially non-numeric
  g =               // g is a recursive function taking
  q =>              // the current rotation q
  x-- ?             // if x is not equal to 0 (decrement it afterwards):
    g(              //   do a recursive call:
      q % 2 <<      //     using the number of bits in the original
      Math.log2(    //     input, left-shift the LSB so that it takes
        n,          //     the place of the MSB
        m = m < q ? //     update m to min(m, q)
          m         //     (this always updates m to q if m is
        :           //     still non-numeric)
          q         //
      ) | q / 2     //     right-shift all other bits by 1 position
    )               //   end of recursive call
  :                 // else:
    m               //   stop and return m
)(x = n)            // initial call to g with q = x = n
```
[Answer]
# MATL, ~~13~~ 12 bytes
```
:"GB@YSXBvX<
```
*1 byte saved thanks to @lmendo*
Try it at [MATL Online](https://matl.io/?code=%3A%22GB%40YSXBvX%3C&inputs=177&version=22.7.4)!
**Explanation**
```
       % Implicitly grab the input (N)
:      % Create an array from [1...N]
"      % For each value in the array
  G    % Grab the input as a number
  B    % Convert to an array of booleans representing the binary equivalent
  @YS  % Circularly shift by the loop index
  XB   % Convert the result from binary to decimal
  v    % Vertically concatenate the entire stack
  X<   % Compute the minimum value so far
       % Implicitly display the result
```
[Answer]
# [Julia 1.0](http://julialang.org/), ~~84~~ 78 bytes
```
!x=(c=string(x,base=2);r=keys(c);min((r.|>i->parse(Int,"0b"*(c^2)[i.+r]))...))
```
[Try it online!](https://tio.run/##dZDRToQwEEXf@YqBmNiuSBhql8CmG33wwW9Y16TLNooCEooRE/8d2wIaHkxuJjd3bs40ff2oSonDOPqDIIXQfVc2z2QIT1IrkdBdJ97UlyYF3dVlQ0gXfe/L630rO63IQ9OHQXwKNqR4SuihjK66I6VRFFE6tobTk@B@kHVbqRwC6t3ql/dP8FP0vFZqrc4goJYt8UPMMY7pJQgBBwQwYss0ShfPrZ2CFJD/xTbhgOjE587sXdOI4bqfuQJzHW5NgpAwGyapNQxXHFtgdmVzx5w6E9loy/7nG58t/MzxM8f5veu2N8wpnd9gPHdXzDThlq3fkx29@Y8fm7uqgl7pXsP0sTlcTCag4w8 "Julia 1.0 – Try It Online")
* `c` is the bitstring of input `x`. Another method would be `lstrip(bitstring(x),'0')`.
* `r` contains the indices in `c` and is iterated over the repeated bitstring `c^2` to get each rotation.
* `min` treats a vector `V` as a single value, so the splat operator is used: `min(V...)`. Another method would be `minimum(V)`.
-6 bytes thanks to MarcMush:
* Replace range `1:length(c)` with iterator `keys(c)`
* [Use broadcasting](https://codegolf.stackexchange.com/a/219504/114865)
[Answer]
# Java 10, 118 bytes
```
n->{var b=n.toString(n,2);for(int l=b.length(),i=l,t;i-->0;n=t<n?t:n)t=n.parseInt((b+b).substring(i,i+l),2);return n;}
```
Input \$n\$; outputs the smallest bit rotation.
[Try it online.](https://tio.run/##bZA9b8MgEIb3/IqTJ5A/ZHeJFEI6d2iWjG0H7BD3UnK24GypivLbXRynnbogeE88PC9nM5r8fPyaGmdCgFeDdF0BILH1J9NY2M/HewCNeIlxaz2QVDG9reIS2DA2sAcCPVG@u47GQ62p4O7AHqkVlD1Jdeq8mBlO14Wz1PKnkBlql7HCPN@VijRv6Zk3JDle7o0PNr4mRJ3WsghDHRYYZpg6ORO95cETkLpNahbph9pFkYfP2OERLrGNWCzePoxcmhy@A9tL0Q1c9HHCjkRSrdebd05SKhoR9/JeD@BXGnWlcKurslSYpvI@@xeEafLHQfn4pNv0Aw)
**Explanation:**
```
n->{                       // Method with Integer as both parameter and return-type
  var b=n.toString(n,2);   //  Convert the input-integer to a binary-String
  for(int l=b.length(),    //  Set `l` to the length of this binary-String
      i=l,t;i-->0          //  Loop `i` in the range (l,0]:
      ;                    //    After every iteration:
       n=t<n?              //     If `t` is smaller than `n`:
             t:n)          //      Set `n` to this new minimum `t`
    t=                     //   Set `t` to:
      n.parseInt(          //    The following binary converted to a base-10 integer:
         (b+b)             //     Append the binary-String to itself
         .substring(i,i+l) //     And then get its substring in the range [i,i+l)
       ,2);
  return n;}               //  Return the modified `n` holding the smallest result
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 18 bytes
```
≔⍘Ｎ²θＩ⍘⌊Ｅθ⭆θ§θ⁺κμ²
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DKbE4NbikKDMvXcMzr6C0xK80Nym1SENTR8EIiAs1rbkCgJIlGs6JxSXIin0z8zJzS3M1fBMLNAp1FCCiUI5jiWdeSmoFiBmQU1qska2jkKsJAiBDNTWt//83NDf/r1uWAwA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔⍘Ｎ²θ
```
Convert the input to binary.
```
Ｉ⍘⌊Ｅθ⭆θ§θ⁺κμ²
```
Generate all of the rotations, take the minimum, and convert back to decimal.
[Answer]
# [Zsh](https://www.zsh.org/), 70 bytes
```
b=$[[##2]$1];for i ({1..$#b})m+=($[2#${b:$i}${b:0:$i}]);printf ${(n)m}
```
[Try it online!](https://tio.run/##FcbBCsAQHIDx@55C@R9oJVzU5EnkYk0csGynybNbLt/v@544A6F9egPWYiwdCKdDbSgh0gVjgP2geTcErMTQ/QFpLPgaR/XdUnkDgk4KzWNeZ6xj2wISSq1yPn8 "Zsh – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
ḋ▼U¡ṙ1ḋ
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8eGOxYYGBv8f7uh@NG1P6KGFD3fONARy/v8HAA "Husk – Try It Online")
```
      ḋ  # convert to bits,
   ¡     # make infinite list by repeatedly
    ṙ1   #   rotating by one position,
  U      # get the longest unique prefix,
 ▼       # get the minimum of this,
ḋ        # and get the value from the bits.
```
[Answer]
# [Desmos](https://desmos.com/calculator), 95 bytes
```
L=[floor(log_2N)...0]
B=mod(floor(N/2^L),2)
f(N)=[total(join(B[i+1...],B[1...i])2^L)fori=L].min
```
Even worse than the fish answer... at least it beats Java :P
[Try It On Desmos!](https://www.desmos.com/calculator/nswp1oanee)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/zapwwl0vnl)
]