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!)
A142721 An even-odd sequence: a(n) = n/2 if n is even, or a(n-1) + 2^floor(log_2(n+1)) otherwise. 0

%I #16 Dec 07 2019 00:47:07

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

%T 29,14,30,15,47,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,95,32,96,33,97,34,98,35,99,36,100

%N An even-odd sequence: a(n) = n/2 if n is even, or a(n-1) + 2^floor(log_2(n+1)) otherwise.

%t a[0] = 0; a[n_] := a[n] = If[Mod[n, 2] == 0, n/2, a[n - 1] + 2^(Floor[Log[2, 1 + n]])]; Table[a[n], {n, 0, 100}]

%t nxt[{n_,a_}]:={n+1,If[EvenQ[n+1],(n+1)/2,a+2^Floor[Log[2,n+2]]]}; Transpose[ NestList[ nxt,{0,0},100]][[2]] (* _Harvey P. Dale_, Feb 26 2013 *)

%o (PARI) a(n)=n\2+if(n%2,2^(log(n+1.5)\log(2))) \\ _Charles R Greathouse IV_, Jan 30 2012

%K nonn,less,easy

%O 0,2

%A _Roger L. Bagula_ and _Gary W. Adamson_, Sep 27 2008

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 17 03:24 EDT 2024. Contains 373432 sequences. (Running on oeis4.)