A153003 Toothpick sequence in the first three quadrants.
0, 1, 4, 7, 10, 16, 25, 31, 34, 40, 49, 58, 70, 91, 115, 127, 130, 136, 145, 154, 166, 187, 211, 226, 238, 259, 286, 316, 361, 427, 487, 511, 514, 520, 529, 538, 550, 571, 595, 610, 622, 643, 670, 700, 745, 811, 871, 898, 910, 931
Offset: 0
Keywords
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
- Index entries for sequences related to toothpick sequences
Programs
-
Mathematica
A139250[n_] := A139250[n] = Module[{m, k}, If[n == 0, Return[0]]; m = 2^(Length[IntegerDigits[n, 2]] - 1); k = (2 m^2 + 1)/3; If[n == m, k, k + 2 A139250[n - m] + A139250[n - m + 1] - 1]]; a[n_] := If[n == 0, 0, (3/4)(A139250[n + 1] - 3) + 1]; a /@ Range[0, 49] (* Jean-François Alcover, Apr 06 2020 *)
-
Python
def msb(n): t=0 while n>>t>0: t+=1 return 2**(t - 1) def a139250(n): k=(2*msb(n)**2 + 1)/3 return 0 if n==0 else k if n==msb(n) else k + 2*a139250(n - msb(n)) + a139250(n - msb(n) + 1) - 1 def a(n): return 0 if n==0 else (a139250(n + 1) - 3)*3/4 + 1 [a(n) for n in range(51)] # Indranil Ghosh, Jul 01 2017
Comments