login
Number of squares and rectangles that are created at the n-th stage in the toothpick structure (see A139250).
9

%I #13 Feb 24 2021 02:48:18

%S 0,0,2,2,0,4,10,6,0,4,8,4,4,20,30,14,0,4,8,4,4,20,28,12,4,16,20,12,28,

%T 72,78,30,0,4,8,4,4,20,28,12,4,16,20,12,28,72,76,28,4,16,20,12,28,68,

%U 68,28,24,52,52,52,128,224,190,62,0,4,8,4,4,20,28,12,4,16,20,12,28,72

%N Number of squares and rectangles that are created at the n-th stage in the toothpick structure (see A139250).

%H David Applegate, Omar E. Pol and N. J. A. Sloane, <a href="/A000695/a000695_1.pdf">The Toothpick Sequence and Other Sequences from Cellular Automata</a>, Congressus Numerantium, Vol. 206 (2010), 157-191. [There is a typo in Theorem 6: (13) should read u(n) = 4.3^(wt(n-1)-1) for n >= 2.]

%H N. J. A. Sloane, <a href="/wiki/Catalog_of_Toothpick_and_CA_Sequences_in_OEIS">Catalog of Toothpick and Cellular Automata Sequences in the OEIS</a>

%F See Maple program for recurrence.

%p # First construct A168131:

%p w := proc(n) option remember; local k,i;

%p if (n=0) then RETURN(0)

%p elif (n <= 3) then RETURN(n-1)

%p else

%p k:=floor(log(n)/log(2)); i:=n-2^k;

%p if (i=0) then RETURN(2^(k-1)-1)

%p elif (i<2^k-2) then RETURN(2*w(i)+w(i+1));

%p elif (i=2^k-2) then RETURN(2*w(i)+w(i+1)+1);

%p else RETURN(2*w(i)+w(i+1)+2);

%p fi; fi; end;

%p # Then construct A160125:

%p r := proc(n) option remember; local k,i;

%p if (n<=2) then RETURN(0)

%p elif (n <= 4) then RETURN(2)

%p else

%p k:=floor(log(n)/log(2)); i:=n-2^k;

%p if (i=0) then RETURN(2^k-2)

%p elif (i<=2^k-2) then RETURN(4*w(i));

%p else RETURN(4*w(i)+2);

%p fi; fi; end;

%p [seq(r(n),n=0..200)];

%p # _N. J. A. Sloane_, Feb 01 2010

%t w [n_] := w[n] = Module[{k, i}, Which[n == 0, 0, n <= 3, n - 1, True, k = Floor[Log[2, n]]; i = n - 2^k; Which[i == 0, 2^(k - 1) - 1, i < 2^k - 2, 2 w[i] + w[i + 1], i == 2^k - 2, 2 w[i] + w[i + 1] + 1, True, 2 w[i] + w[i + 1] + 2]]];

%t r[n_] := r[n] = Module[{k, i}, Which[n <= 2, 0, n <= 4, 2, True, k = Floor[Log[2, n]]; i = n - 2^k; Which[i == 0, 2^k - 2, i <= 2^k - 2, 4 w[i], True, 4 w[i] + 2]]];

%t Array[r, 78] (* _Jean-François Alcover_, Apr 15 2020, from Maple *)

%Y First differences of A160124.

%Y Cf. toothpick sequence A139250.

%Y Cf. A159786, A159787, A159788, A159789, A160124, A160126, A160127.

%K nonn

%O 1,3

%A _Omar E. Pol_, May 03 2009

%E Terms beyond a(10) from _R. J. Mathar_, Jan 21 2010