login
Odd-indexed terms are absolute values of differences.
2

%I #34 Jan 28 2022 07:43:36

%S 1,2,1,4,3,6,1,8,3,10,5,12,7,14,5,16,7,18,5,20,7,22,5,24,7,26,9,28,11,

%T 30,9,32,11,34,13,36,15,38,13,40,15,42,17,44,19,46,17,48,19,50,17,52,

%U 19,54,17,56,19,58,21,60,23,62,21,64,23,66,21,68,23,70,21,72,23,74,25,76,27,78,25,80,27,82,25

%N Odd-indexed terms are absolute values of differences.

%C The precise definition is: Set a(2n)=2n for all n, set a(1)=1, and for n >= 1 choose a(2n+1) so that the subsequence {a(2i+1), i>=0} is the same as the sequence of differences {|a(j+1)-a(j)|, j>=0}.

%H Reinhard Zumkeller, <a href="/A234586/b234586.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/FirstDiffImpair.htm">The first differences of S ...</a>

%H Eric Angelini, <a href="/A234586/a234586.pdf">The first differences of S ...</a> [Cached copy, with permission]

%F There is a surprising connection with the Thue-Morse sequence A010060. If the k-th run of equal terms in A010060 (k>=0) has length L (L=1 or 2, see A026465), replace it by 2L copies of the pair 4k+1, 4k+3. This produces the odd-indexed terms of the sequence (ignoring the initial 1): 0 1 1 0 1 0 0 1 ... becomes 1 3 1 3 5 7 5 7 5 7 5 7 9 11 9 11 13 ... - _N. J. A. Sloane_, Dec 31 2013

%e We start by alternating even numbers and "holes" like this:

%e S = . 2 . 4 . 6 . 8 . 10 . 12 . 14 . 16 . 18 . 20 . 22 .....

%e We fill the first hole with '1' and the second and third holes with x, y:

%e S = 1 2 x 4 y 6 . 8 . 10 . 12 . 14 . 16 . 18 . 20 . 22 .....

%e The absolute values of differences are 1, |x-2|, |4-x|, ... which must equal 1, x, y, ..., which forces x=1, y=3. And so on.

%p with(LinearAlgebra): M:=1000; S:=Array(1..2*M); S[1]:=1; S[3]:=1;

%p for i from 1 to M do S[2*i]:=2*i; od:

%p for i from 2 to M-1 do S[2*i+1]:=abs(S[i+2]-S[i+1]); od:

%p [seq(S[i],i=1..2*M)];

%t a[1] = a[3] = 1; a[n_?EvenQ] := n; a[n_] := a[n] = Abs[a[(n-1)/2+2]-a[(n-1)/2+1]]; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Jan 13 2015 *)

%o (Haskell)

%o import Data.List (transpose)

%o a234586 n = a234586_list !! (n-1)

%o a234586_list = concat (transpose [a234587_list, [2, 4 ..]])

%o a234587_list = 1 : 1 : (drop 2 $

%o map abs $ zipWith (-) a234586_list $ tail a234586_list)

%o -- _Reinhard Zumkeller_, Jul 15 2014

%Y Cf. A010060, A026465, A234587 (the odd-indexed terms).

%K nonn,nice

%O 1,2

%A _Eric Angelini_, Dec 31 2013

%E Entered by _N. J. A. Sloane_ on _Eric Angelini_'s behalf and submitted for the 2014 JMM competition with his permission.