OFFSET
1,2
COMMENTS
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}.
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Eric Angelini, The first differences of S ...
Eric Angelini, The first differences of S ... [Cached copy, with permission]
FORMULA
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
EXAMPLE
We start by alternating even numbers and "holes" like this:
S = . 2 . 4 . 6 . 8 . 10 . 12 . 14 . 16 . 18 . 20 . 22 .....
We fill the first hole with '1' and the second and third holes with x, y:
S = 1 2 x 4 y 6 . 8 . 10 . 12 . 14 . 16 . 18 . 20 . 22 .....
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.
MAPLE
with(LinearAlgebra): M:=1000; S:=Array(1..2*M); S[1]:=1; S[3]:=1;
for i from 1 to M do S[2*i]:=2*i; od:
for i from 2 to M-1 do S[2*i+1]:=abs(S[i+2]-S[i+1]); od:
[seq(S[i], i=1..2*M)];
MATHEMATICA
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 *)
PROG
(Haskell)
import Data.List (transpose)
a234586 n = a234586_list !! (n-1)
a234586_list = concat (transpose [a234587_list, [2, 4 ..]])
a234587_list = 1 : 1 : (drop 2 $
map abs $ zipWith (-) a234586_list $ tail a234586_list)
-- Reinhard Zumkeller, Jul 15 2014
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Eric Angelini, Dec 31 2013
EXTENSIONS
Entered by N. J. A. Sloane on Eric Angelini's behalf and submitted for the 2014 JMM competition with his permission.
STATUS
approved