The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A038572 a(n) = n rotated one binary place to the right. 30

%I #34 Jan 23 2023 02:31:18

%S 0,1,1,3,2,6,3,7,4,12,5,13,6,14,7,15,8,24,9,25,10,26,11,27,12,28,13,

%T 29,14,30,15,31,16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,

%U 25,57,26,58,27,59,28,60,29,61,30,62,31,63,32,96,33,97,34,98,35,99,36,100

%N a(n) = n rotated one binary place to the right.

%C Iterating a(n), a(a(n)), ... eventually leads to 2^A000120(n) - 1. - _Franklin T. Adams-Watters_, Apr 09 2010

%H Indranil Ghosh, <a href="/A038572/b038572.txt">Table of n, a(n) for n = 0..20000</a> (first 1024 terms from T. D. Noe)

%F a(n) = A053645(n) * A000035(n) + A004526(n) = most significant bit(n) * least significant bit(n) + floor(n/2).

%F a(0)=0, a(1)=1, a(2n) = n, a(2n+1) = 2a(n) + 2a(n+1) - n. - _Ralf Stephan_, Oct 24 2003

%e For n = 35, 35_10 = 100011_2, which after rotating one binary place to the right becomes 110001. Now, 110001_2 = 49_10. So, a(35) = 49. - _Indranil Ghosh_, Jan 21 2017

%p A038572 := proc(n)

%p convert(n,base,2) ;

%p ListTools[Rotate](%,1) ;

%p add( op(i,%)*2^(i-1),i=1..nops(%)) ;

%p end proc: # _R. J. Mathar_, May 20 2016

%t Table[ FromDigits[ RotateRight[ IntegerDigits[n, 2]], 2], {n, 0, 80}] (* _Robert G. Wilson v_ *)

%o (Haskell)

%o a038572 0 = 0

%o a038572 n = a053645 n * m + n' where (n', m) = divMod n 2

%o -- _Reinhard Zumkeller_, Dec 03 2012

%o (PARI) a(n)=if(n<2,return(n)); my(d=binary(n)); fromdigits(concat(d[#d], d[1..#d-1]),2) \\ _Charles R Greathouse IV_, Sep 02 2015

%o (Python)

%o def A038572(n):

%o x = bin(n)[2:]

%o return int(x[-1]+x[:-1],2) # _Indranil Ghosh_, Jan 21 2017

%o (Python)

%o def A038572(n): return (n>>1)+(1<<n.bit_length()-1 if n&1 else 0) # _Chai Wah Wu_, Jan 22 2023

%Y Cf. A006257, A088146.

%K easy,base,nonn,nice

%O 0,4

%A _Marc LeBrun_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 12 14:10 EDT 2024. Contains 373331 sequences. (Running on oeis4.)