A025480 a(2n) = n, a(2n+1) = a(n).
0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15, 0, 16, 8, 17, 4, 18, 9, 19, 2, 20, 10, 21, 5, 22, 11, 23, 1, 24, 12, 25, 6, 26, 13, 27, 3, 28, 14, 29, 7, 30, 15, 31, 0, 32, 16, 33, 8, 34, 17, 35, 4, 36, 18, 37, 9, 38, 19, 39, 2, 40, 20, 41, 10
Offset: 0
Examples
From Deuard Worthen (deuard(AT)raytheon.com), Jan 27 2006: (Start) The sequence can be constructed as a triangle as: 0 0 1 0 2 1 3 0 4 2 5 1 6 3 7 0 8 4 9 2 10 5 11 1 12 6 13 3 14 7 15 ... At each stage we interleave the next 2^m numbers in the previous row. (End) Left=0/1, Right=1/0: StB=A007305/A047679; Left=0/1, Right=1/1: StB=A007305/A007306; Left=1/3, Right=2/3: StB=A153161/A153162. - _Reinhard Zumkeller_, Dec 22 2008
References
- L. Levine, Fractal sequences and restricted Nim, Ars Combin. 80 (2006), 113-127.
Links
- N. J. A. Sloane, Table of n, a(n) for n = 0..10000
- Josef Eschgfäller and Andrea Scarpante, Dichotomic random number generators, arXiv:1603.08500 [math.CO], 2016.
- Ralf Hinze, Concrete stream calculus: An extended study, J. Funct. Progr. 20 (5-6) (2010) 463-535, doi, Section 3.2.4.
- L. Levine, Fractal sequences and restricted Nim, arXiv:math/0409408 [math.CO], 2004.
- Ralf Stephan, Some divide-and-conquer sequences ....
- Ralf Stephan, Table of generating functions.
- Paul Tarau, A Groupoid of Isomorphic Data Transformations, Calculemus 2009, 8th International Conference, MKM 2009, pp. 170-185, Springer, LNAI 5625.
- Index entries for sequences related to the Josephus Problem.
Crossrefs
Programs
-
Haskell
import Data.List interleave xs ys = concat . transpose $ [xs,ys] a025480 = interleave [0..] a025480 -- Cale Gibbard, Nov 18 2009
-
Haskell
Cf. comments by Worthen and Hasler. import Data.List (transpose) a025480 n k = a025480_tabf !! n !! k a025480_row n = a025480_tabf !! n a025480_tabf = iterate (\xs -> concat $ transpose [xs, [length xs .. 2 * length xs - 1]]) [0] a025480_list = concat $ a025480_tabf -- Reinhard Zumkeller, Apr 29 2012
-
Maple
A025480 := proc(n) option remember ; if type(n,'even') then n/2 ; else procname((n-1)/2) ; end if; end proc: seq(A025480(n),n=0..100) ; # R. J. Mathar, Jul 16 2020
-
Mathematica
a[n_] := a[n] = If[OddQ@n, a[(n - 1)/2], n/2]; Table[ a[n], {n, 0, 83}] (* Robert G. Wilson v, Mar 30 2006 *) Table[BitShiftRight[n, IntegerExponent[n, 2] + 1], {n, 100}] (* IWABUCHI Yu(u)ki, Oct 13 2012 *)
-
PARI
a(n)={while(n%2,n\=2);n\2} \\ M. F. Hasler, May 03 2008
-
PARI
A025480(n)=n>>valuation(n*2+2,2) \\ M. F. Hasler, Apr 12 2012
-
Python
def A025480(n): return n>>((~(n+1)&n).bit_length()+1) # Chai Wah Wu, Jul 13 2022
-
Sage
A025480 = lambda n: odd_part(n+1)//2 [A025480(n) for n in (0..83)] # Peter Luschny, May 20 2014
Formula
a(n) = A003602(n+1) - 1. [Corrected by Max Alekseyev, May 05 2022]
a(n) = A153733(n)/2. - Reinhard Zumkeller, Dec 31 2008
2^A007814(n+1)*(2*a(n)+1) = n+1. (See functions hd, tl and cons in [Paul Tarau 2009].) - Paul Tarau (paul.tarau(AT)gmail.com), Mar 21 2010
a(3*n + 1) = A173732(n). - Reinhard Zumkeller, Apr 29 2012
a((2*n+1)*2^p-1) = n, p >= 0 and n >= 0. - Johannes W. Meijer, Jan 24 2013
a(n) = n - A225381(n). - Marcus Hedbring, May 18 2013
G.f.: -1/(1-x) + Sum_{k>=0} x^(2^k-1)/(1-2*x^2^(k+1)+x^2^(k+2)). - Ralf Stephan, May 19 2013
a(n) = floor(n / 2^A001511(n+1)). - Adam Shelly, Mar 05 2019
Recursion: a(0) = 0; a(n + 1) = a(a(n)) if a(n) is a first occurrence of a term, else a(n + 1) = n - a(n-1). - David James Sycamore, Apr 29 2020
a(n) * 2^(A007814(n+1)+1) + 2^A007814(n+1) - 1 = n (equivalent to the formula given in the comment by Paul Tarau). - Ruud H.G. van Tol, Apr 14 2023
Sum_{k=1..n} a(k) = n^2/6 + O(n). - Amiram Eldar, Aug 07 2023
Extensions
Edited by M. F. Hasler, Mar 16 2018
Comments