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!)
A049039 Geometric Connell sequence: 1 odd, 2 even, 4 odd, 8 even, ... 9

%I #36 Aug 01 2022 21:19:51

%S 1,2,4,5,7,9,11,12,14,16,18,20,22,24,26,27,29,31,33,35,37,39,41,43,45,

%T 47,49,51,53,55,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,

%U 92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,121,123,125

%N Geometric Connell sequence: 1 odd, 2 even, 4 odd, 8 even, ...

%H Reinhard Zumkeller, <a href="/A049039/b049039.txt">Rows n=1..13 of triangle, flattened</a>

%H Ralf Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences ...</a>

%H Ralf Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a>

%F a(n) = 2n - 1 - floor(log_2(n)).

%F a(2^n-1) = 2^(n+1) - (n+2) = A000295(n+1), the Eulerian numbers.

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

%p Digits := 100: [seq(2*n-1-floor(evalf(log(n)/log(2))), n=1..100)];

%t a[0] = 0; a[n_?EvenQ] := a[n] = a[n/2]+n-1; a[n_?OddQ] := a[n] = a[(n-1)/2]+n; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Dec 27 2011, after _Ralf Stephan_ *)

%o (Haskell)

%o a049039 n k = a049039_tabl !! (n-1) !! (k-1)

%o a049039_row n = a049039_tabl !! (n-1)

%o a049039_tabl = f 1 1 [1..] where

%o f k p xs = ys : f (2 * k) (1 - p) (dropWhile (<= last ys) xs) where

%o ys = take k $ filter ((== p) . (`mod` 2)) xs

%o -- _Reinhard Zumkeller_, Jan 18 2012, Jul 08 2011

%o (PARI) a(n) = n<<1 - 1 - logint(n,2); \\ _Kevin Ryde_, Feb 12 2022

%o (Python)

%o def A049039(n): return (n<<1)-n.bit_length() # _Chai Wah Wu_, Aug 01 2022

%Y Cf. A337300 (partial sums), A043529 (first differences).

%Y Cf. A001614, A033292, A030196, A000295, A050487, A050488.

%Y Cf. A160464, A160465 and A160473. - _Johannes W. Meijer_, May 24 2009

%K easy,nonn,nice,tabf

%O 1,2

%A _James A. Sellers_

%E Keyword tabf added by _Reinhard Zumkeller_, Jan 22 2012

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 April 19 21:09 EDT 2024. Contains 371798 sequences. (Running on oeis4.)