A330005 a(n) counts the square-words immediately before a(n), with a(1) = 0.
0, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 3, 0, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 3, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 1, 1, 3, 1, 1, 1, 0, 0, 1, 0
Offset: 1
Examples
S = 0, ... We start with a(1) = 0 as this 0 means: "I don't see any square on my immediate left"; S = 0,0, ... We extend S with a(2) = 0 as this 0 says the same as above: "I don't see any square on my immediate left". Note that no other integer would fit without contradiction [a(2) = 1, for instance, would say that there is one square on the immediate left of "1", which is not the case - a lonely symbol cannot form a square]. S = 0,0,1, ... As we now see the square {00}, S is extended with a(3) = 1 S = 0,0,1,0, ... No square in sight, we thus extend S with a(4) = 0 [the word "immediate" is important: "There is no square on the immediate left of a(4) = 0"]; S = 0,0,1,0,0, ... No visible square again, so a(5) = 0; S = 0,0,1,0,0,1, ... We see here that a(6) must be 1, as this "1" is immediately after the square {00} S = 0,0,1,0,0,1,1, ... Yes: a(7) = 1 because a(7) sees 1 square on its immediate left, which is formed by {001,001}; S = 0,0,1,0,0,1,1,2, ... We see a third symbol entering S, the integer "2"; the reason is that 2 sees two squares on its immediate left, the first one being {11} and the second one {00} (again, the remote square {00} that opens S is not "immediately" to the left of 2, so we don't count it); etc.
Links
- Jean-Marc Falcoz, Table of n, a(n) for n = 1..10001
Programs
-
PARI
A330005_upto(N,A=0)={for(n=2,#A=Vec(A,N), A[n]=sum(L=1,(n-1)\2, if(A[n-L..n-1]==A[n-L*2..n-L-1] &&(L*3>=n || A[n-L..n-1]!=A[n-L*3..n-L*2-1]), A[n-L*2+1]+1)));A} \\ Optional arg A specifies starting value. - M. F. Hasler, Nov 28 2019
Comments