login
A member of a family of generalizations of van Eck's sequence as defined below.
0

%I #12 Jul 27 2019 16:52:46

%S 0,0,0,2,0,2,2,3,0,4,0,2,5,0,3,7,0,3,3,4,10,0,5,10,3,6,0,5,5,6,4,11,0,

%T 6,4,4,5,8,0,6,6,7,26,0,5,8,8,9,0,5,5,6,11,21,0,6,4,21,4,2,48,0,7,21,

%U 6,9,18,0,6,4,11,18,5,22,0,7,13,0,3,54,0,3,3,4,14,0,5,14,3,6,21,27,0,7,18,23,0,4,14,11

%N A member of a family of generalizations of van Eck's sequence as defined below.

%C For n >= 1, if there exists an m < n-1 such that a(m) = a(n), take the largest such m and set a(n+1) = n-m; otherwise a(n+1) = 0. Start with a(1) = a(2) = 0.

%C T: let 0 <= k < l. For n > k, if there exists an m <= n-l such that a(m) = a(n-k), take the largest such m and set a(n+1) = n-m; otherwise a(n+1) = 0. Start with a(1) = ... = a(l) = 0. Setting k = 0, l = 1 produces van Eck's sequence A181391; setting k = 0, l = 2 produces this sequence.

%o (MATLAB)

%o function VEg = VE_generalized(N, k, l)

%o assert(l > k);

%o VEg = zeros(1, l);

%o for n = l:(N - 1)

%o prev = VEg(n - k);

%o VEg(n + 1) = 0;

%o for j = (n - l):-1:1

%o if VEg(j) == prev

%o VEg(n + 1) = n - j;

%o break

%o end

%o end

%o end

%o end

%Y Cf. A181391.

%K easy,nonn

%O 1,4

%A _Christian Schroeder_, Jul 12 2019