OFFSET
1,2
COMMENTS
By rotating the binary digits of n, it is meant: Write n in binary without any leading 0's. To rotate this string to the right, say, by one position, first remove the rightmost digit and then append it on the left side of the remaining string. (So the least significant digit becomes the most significant digit.) Here, leading 0's are not removed after the first rotation, so that each binary string being rotated has the same number of binary digits as n.
Alternatively, compute n in binary and denote the number of digits by d. Concatenate the binary number to itself. In the new "number", find the smallest binary number with length d and a leading 1. - David A. Corneth, Sep 28 2017
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..8190
EXAMPLE
13 in binary is 1101. Rotating this just once to the right, we get 1110, 14 in decimal. If we rotate twice to the right, we would have had 0111 = 7 in decimal. Rotating 3 times, we end up with 1011, which is 11 in decimal. Rotating 4 times, we end up at the beginning with 1101 = 13. 7 is the smallest of these, but it contains a 0 in the leftmost position of its 4-digit binary representation. 11 (decimal), on the other hand, is the smallest with a 1 in the leftmost position of its 4-digit binary representation. So a(13) = 11.
20 in binary is 10100 and has 5 digits. Concatenating the binary expansion of 20 to itself gives 1010010100. The shortest binary number of length 5 is 10010, which corresponds to 18 in decimal. Therefore, a(20) = 18. - David A. Corneth, Sep 28 2017
MAPLE
a:= proc(n) local i, k, m, s;
k, m, s:= ilog2(n), n, n;
for i to k do m:= iquo(m, 2, 'd') +d*2^k;
if d=1 then s:=s, m fi od;
min(s)
end:
seq(a(n), n=1..80); # Alois P. Heinz, May 24 2012
MATHEMATICA
Table[With[{d = IntegerDigits[n, 2]}, Min@ Map[FromDigits[#, 2] &, Select[Map[RotateRight[d, #] &, Range[Length@ d]], First@ # == 1 &]]], {n, 73}] (* Michael De Vlieger, Sep 23 2017 *)
PROG
(PARI) a(n) = {my(b = binary(n), l = List(), m = #b, v, r = 2^m); b = concat(b, b); for(i=1, m, if(b[i]==1, r = min(r, fromdigits(vector(m, j, b[i + j - 1]), 2)))); r} \\ David A. Corneth, Sep 28 2017
CROSSREFS
KEYWORD
AUTHOR
Leroy Quet, Jul 25 2009
EXTENSIONS
Corrected and extended by Sean A. Irvine, Nov 08 2009
STATUS
approved