This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A049039 #37 Jul 02 2025 16:01:57 %S A049039 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 A049039 47,49,51,53,55,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90, %U A049039 92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,121,123,125 %N A049039 Geometric Connell sequence: 1 odd, 2 even, 4 odd, 8 even, ... %H A049039 Reinhard Zumkeller, <a href="/A049039/b049039.txt">Rows n=1..13 of triangle, flattened</a> %H A049039 Ralf Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences ...</a> %H A049039 Ralf Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a> %F A049039 a(n) = 2n - 1 - floor(log_2(n)). %F A049039 a(2^n-1) = 2^(n+1) - (n+2) = A000295(n+1), the Eulerian numbers. %F A049039 a(0)=0, a(2n) = a(n) + 2n - 1, a(2n+1) = a(n) + 2n + 1. - _Ralf Stephan_, Oct 11 2003 %p A049039 Digits := 100: [seq(2*n-1-floor(evalf(log(n)/log(2))), n=1..100)]; %t A049039 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 A049039 (Haskell) %o A049039 a049039 n k = a049039_tabl !! (n-1) !! (k-1) %o A049039 a049039_row n = a049039_tabl !! (n-1) %o A049039 a049039_tabl = f 1 1 [1..] where %o A049039 f k p xs = ys : f (2 * k) (1 - p) (dropWhile (<= last ys) xs) where %o A049039 ys = take k $ filter ((== p) . (`mod` 2)) xs %o A049039 -- _Reinhard Zumkeller_, Jan 18 2012, Jul 08 2011 %o A049039 (PARI) a(n) = n<<1 - 1 - logint(n,2); \\ _Kevin Ryde_, Feb 12 2022 %o A049039 (Python) %o A049039 def A049039(n): return (n<<1)-n.bit_length() # _Chai Wah Wu_, Aug 01 2022 %Y A049039 Cf. A337300 (partial sums), A043529 (first differences). %Y A049039 Cf. A001614, A033292, A030196, A000295, A050487, A050488. %Y A049039 Cf. A160464, A160465 and A160473. - _Johannes W. Meijer_, May 24 2009 %K A049039 easy,nonn,nice,tabf %O A049039 1,2 %A A049039 _James Sellers_ %E A049039 Keyword tabf added by _Reinhard Zumkeller_, Jan 22 2012