A139709 Take n in binary. Rotate the binary digits to the left until a 1 once again appears as the leftmost digit. a(n) is result written in binary.
1, 10, 11, 100, 110, 101, 111, 1000, 1100, 1010, 1110, 1001, 1011, 1101, 1111, 10000, 11000, 10100, 11100, 10010, 10110, 11010, 11110, 10001, 10011, 10101, 10111, 11001, 11011, 11101, 11111, 100000, 110000, 101000, 111000, 100100, 101100
Offset: 1
Examples
For n = 11 (in decimal): 11 (in decimal) = 1011 in binary. Rotate once to the left, getting 0111. The leftmost digit is a 0, so rotate again to the left, getting 1110. A 1 is the leftmost digit, so stop here. a(11) therefore is 1110 (which is 14 in decimal).
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Programs
-
Maple
A007088 := proc(L) local i ; add(op(i,L)*10^(i-1),i=1..nops(L)) : end: A139709 := proc(n) local a; a := ListTools[Rotate](convert(n,base,2),-1) ; while op(-1,a) = 0 do a := ListTools[Rotate](a,-1) ; od: A007088(a) ; end: seq(A139709(n),n=1..80) ; # R. J. Mathar, May 04 2008
-
Mathematica
Array[FromDigits@ NestWhile[RotateLeft, IntegerDigits[#, 2], First@ # == 0 &, {2, 1}] &, 37] (* Michael De Vlieger, Oct 22 2017 *)
-
PARI
rot(n) = if(#Str(n)==1, v=vector(1), v=vector(#n-1)); for(i=2, #n, v[i-1]=n[i]); u=vector(#n); for(i=1, #n, u[i]=n[i]); v=concat(v, u[1]); v a(n) = my(b=rot(binary(n))); while(b[1]==0, b=rot(b)); subst(Pol(b), x, 10) \\ Felix Fröhlich, Oct 22 2017
Extensions
More terms from R. J. Mathar, May 04 2008
Comments