OFFSET
0,3
COMMENTS
From M. F. Hasler, Oct 20 2019: (Start)
The sequence A285326/2 is characterized by a(2n) = 2*a(n) (n >= 0) and a(2n-1) = n (n >= 1). This implies the property defining this sequence: If n = 2k, then n - a(n-1) = 2k - a(2k-1) = 2k - k = k, so a(n - a(n-1)) + a(floor(n/2)) = a(k) + a(k) = 2*a(k) = a(2k) = a(n). If n = 2k-1, then n - a(n-1) = 2k-1 - a(2k-2) = 2k-1 - 2*a(k-1), whence a(n - a(n-1)) + a(floor(n/2)) = a(2(k - a(k-1)) - 1) + a(k-1) = k - a(k-1) + a(k-1) = k = a(2k-1) = a(n). Thus, A285326/2 satisfies the definition of this sequence.
The sequence is equal to itself multiplied by 2 and interleaved with the positive integers. (This is equivalent to the above characterization.)
The sequence repeats the pattern [A, B, C, C] where in the n-th occurrence C = 2n, B = C - 1, A = C if n is even, A = C + 2 if n == 3 (mod 4), and A = 16*a((n-1)/4) otherwise. This yields a simpler formula for all terms except for indices which are multiples of 16. (End)
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
FORMULA
a(0) = 0; a(1) = a(2) = 1; a(n) = a(n - a(n-1)) + a(floor(n/2)).
a(n) = A285326(n)/2, equivalent to the above: see comments for the proof. - M. F. Hasler, Oct 19 2019
MATHEMATICA
a[0] = 0; a[1] = 1;
a[n_] := a[n] = a[n - a[n - 1]] + a[Floor[n/2]];
Table[a[n], {n, 0, 200}]
PROG
(Haskell)
a140472 n = a140472_list !! n
a140472_list = 0 : 1 : h 2 1 where
h x y = z : h (x + 1) z where z = a140472 (x - y) + a140472 (x `div` 2)
-- Reinhard Zumkeller, Jul 20 2012
(Magma) I:=[1, 2]; [0] cat [n le 2 select I[n] else Self(n-Self(n-1))+Self(Floor((n) div 2)):n in [1..75]]; // Marius A. Burtea, Aug 16 2019
(PARI) a(n)=(n+bitand(n, -n))\2 \\ M. F. Hasler, Oct 19 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Roger L. Bagula and Gary W. Adamson, Jun 28 2008
EXTENSIONS
Offset corrected by Reinhard Zumkeller, Jul 20 2012
STATUS
approved