%I #11 Apr 20 2017 11:47:42
%S 2,5,4,17,-1,109,8,65,89,1115,-1,7297,2531,4369,16,257,155174,195814,
%T 495146,5201,1334551,1725452,1485482,-1,-1,-1,17256565,277691849,
%U 6145997,2029501,32,1025,67672804,1157011598,12054050100,22287270331,15597512810,-1
%N Consider a string of n 1. From left to right for any couple of consecutive numbers apply the transform 11 -> 10, 10 -> 11, 00 -> 00, 01 -> 01. At any further step restart the process considering the value of the rightmost digit as input to the leftmost one to apply the transform again. Sequence gives the number of steps necessary to reach again a string of n 1 or -1 if such a number does not exist.
%C a(n) <= 2^n if it exists.
%C a(2^k) = 2^k.
%C a(2^k + 1) = 2^(2*k) + 1.
%C Up to a(34), it appears that if the number does not exist the configuration of the first step is repeated further on: for a(6) it happens after 22 steps (see example), 1086 for a(12), 2192338 for a(25), 22996 for a(26), 41943036 for a(27).
%H Lars Blomberg, <a href="/A281922/b281922.txt">Table of n, a(n) for n = 2..42</a>
%e a(5) = 17. We start with 1 1 1 1 1, then the first two digit at left are 1 1 and applying the transform we get 1 0 1 1 1; again, the second and third digit from left are 0 1 and applying the transform we get 1 0 1 1 1; the third and fourth digit from left are 1 1 and we get 1 0 1 0 1; the fourth and fifth digit from left are 0 1 and we get 1 0 1 0 1. This is the result of the first step. To start the second one we consider the rightmost digit of the first step, that is 1, as input of the leftmost digit, that is another 1. So, applying the transform 1 1 -> 1 0, we get 0 0 1 0 1; now the first and second digit at left are 0 0 that results in 0 0 1 0 1; the second and third digit at left are 0 1 that results in 0 0 1 0 1; the third and fourth digit at left are 1 0 that results in 0 0 1 1 1; the fourth and fifth digit from left are 1 1 that results in 0 0 1 1 0. This is the result of the second step. Here below the list of all the steps leading back to 1 1 1 1 1:
%e 0 1 1 1 1 1
%e 1 1 0 1 0 1
%e 2 0 0 1 1 0
%e 3 0 0 1 0 0
%e 4 0 0 1 1 1
%e 5 1 1 0 1 0
%e 6 1 0 0 1 1
%e 7 0 0 0 1 0
%e 8 0 0 0 1 1
%e 9 1 1 1 0 1
%e 10 0 1 0 0 1
%e 11 1 0 0 0 1
%e 12 0 0 0 0 1
%e 13 1 1 1 1 0
%e 14 1 0 1 0 0
%e 15 1 1 0 0 0
%e 16 1 0 0 0 0
%e 17 1 1 1 1 1
%e a(6) = -1 because after 22 steps we get again 1 0 1 0 1 0 (first step):
%e 0 1 1 1 1 1 1
%e 1 1 0 1 0 1 0
%e 2 1 1 0 0 1 1
%e 3 0 1 1 1 0 1
%e 4 1 0 1 0 0 1
%e 5 0 0 1 1 1 0
%e 6 0 0 1 0 1 1
%e 7 1 1 0 0 1 0
%e 8 1 0 0 0 1 1
%e 9 0 0 0 0 1 0
%e 10 0 0 0 0 1 1
%e 11 1 1 1 1 0 1
%e 12 0 1 0 1 1 0
%e 13 0 1 1 0 1 1
%e 14 1 0 1 1 0 1
%e 15 0 0 1 0 0 1
%e 16 1 1 0 0 0 1
%e 17 0 1 1 1 1 0
%e 18 0 1 0 1 0 0
%e 19 0 1 1 0 0 0
%e 20 0 1 0 0 0 0
%e 21 0 1 1 1 1 1
%e 22 1 0 1 0 1 0
%p with(numtheory): P:=proc(q) local a,b,j,k,n,ok,ok2,s,t;
%p for n from 2 to q do a:=array(1..n); b:=array(1..n);
%p for k from 1 to n do a[k]:=1; if k mod 2=0 then b[k]:=0; else b[k]:=1; fi; od;
%p for k from 1 to n-1 do if a[k]=1 then a[k+1]:=(a[k+1]+1) mod 2; fi; od;
%p t:=1; ok:=1; s:=0; while n>s do t:=t+1; if a[n]=1 then a[1]:=(a[1]+1) mod 2; fi;
%p for k from 1 to n-1 do if a[k]=1 then a[k+1]:=(a[k+1]+1) mod 2; fi; od;
%p ok2:=1; for j from 1 to n do if a[j]<>b[j] then ok2:=0; break; fi; s:=add(a[k],k=1..n); od;
%p if ok2=1 then ok:=0; print(-1); break; fi; od; if ok=1 then print(t); fi; od; end: P(100);
%Y Cf. A046932.
%K sign,hard
%O 2,1
%A _Paolo P. Lava_, Feb 15 2017
%E a(35)-a(39) from _Lars Blomberg_, Apr 20 2017