OFFSET
-1,3
LINKS
David Applegate, Omar E. Pol and N. J. A. Sloane, The Toothpick Sequence and Other Sequences from Cellular Automata, 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.]
N. J. A. Sloane, Catalog of Toothpick and Cellular Automata Sequences in the OEIS
FORMULA
a(-1)=0, a(0)=1, a(1)=6. For n >= 2, let n = 2^k+j with 0 <= j < 2^k, and write j+1 = 2^m*(2t+1). Then a(n) = 4*(3^(m+1)-2^(m+1))*3^wt(t), except if j=2^k-1 we must add 2^(k+1) to the result (here wt(t) = A000120(t)).
Recurrence: a(-1)=0, a(0)=1, a(1)=6. For n>=2, write n = 2^k + j, with 0 <= j < 2^k. If j+1 is a power of 2, say j+1 = 2^r, set f=j+1 if r<k, f=3(j+1) if r=k, and otherwise set f=0. Then a(n) = 3*a(j) + f. (The explicit formula in the previous line is better.)
EXAMPLE
Can be written in the form of a triangle:
0,
1,
6,
4,24,
4,20,12,84,
4,20,12,76,12,60,36,276,
4,20,12,76,12,60,36,260,12,60,36,228,36,180,108,876,
4,20,12,76,12,60,36,260,12,60,36,228,36,180,108,844,12,60,36,228,36,180,108,780,36,180,108,684,108,540,324,2724,
...
MAPLE
a:=proc(n) option remember; local f, j, k, t1;
if n=-1 then RETURN(0); elif n=0 then RETURN(1); elif n=1 then RETURN(6);
else k:=floor(log(n)/log(2)); j:=n-2^k; t1 := 2^floor(log(j+1)/log(2));
if t1=j+1 and j < 2^k-1 then f := j+1 elif t1=j+1 then f := 3*(j+1) else f := 0; fi;
RETURN(3*a(j)+f);
fi;
end;
[seq(a(n), n=-1..200)];
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
N. J. A. Sloane, Apr 14 2010
STATUS
approved