|
%I
%S 0,0,1,3,1,3,2,2,1,3,2,1,3,1,3,2,1,3,1,3,2,2,1,3,2,2,1,3,1,3,2,1,3,2,
%T 2,1,3,2,1,3,1,3,2,2,1,3,2,2,1,3,2,1,3,1,3,2,1,3,1,3,2,2,1,3,2,1,3,1,
%U 3,2,1,3,2,2,1,3,2,2,1,3,1,3,2,1,3,1,3,2,2,1,3,2,1,3,1,3,2,1,3,1,3,2,2,1,3
%N Backwards Van Eck transform of A000002.
%C Given a sequence a, the backwards Van Eck transform b is defined as follows: If a[n] has already appeared in a, let a[m] be the most recent occurrence, and set b[n]=n-m; otherwise b[n]=0.
%C The forwards Van Eck transform of A000002 is A078929.
%p ECKb:=proc(a) local b,i,m,n;
%p if whattype(a) <> list then RETURN([]); fi:
%p b:=[0];
%p for n from 2 to nops(a) do
%p # has a(n) appeared before?
%p m:=0;
%p for i from n-1 by -1 to 1 do
%p if (a[i]=a[n]) then m:=n-i; break; fi
%p od:
%p b:=[op(b),m];
%p od:
%p RETURN(b);
%p end:
%Y Cf. A000002, A181391, A171898, A078929.
%K nonn
%O 1,4
%A _N. J. A. Sloane_, Oct 22 2010
|