cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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, 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, 68, 28, 24, 52, 52, 52, 128, 224, 190, 62, 0, 4, 8, 4, 4, 20, 28, 12, 4, 16, 20, 12, 28, 72
Offset: 1

Views

Author

Omar E. Pol, May 03 2009

Keywords

Crossrefs

First differences of A160124.
Cf. toothpick sequence A139250.

Programs

  • Maple
    # First construct A168131:
    w := proc(n) option remember; local k,i;
    if (n=0) then RETURN(0)
    elif (n <= 3) then RETURN(n-1)
    else
    k:=floor(log(n)/log(2)); i:=n-2^k;
    if (i=0) then RETURN(2^(k-1)-1)
    elif (i<2^k-2) then RETURN(2*w(i)+w(i+1));
    elif (i=2^k-2) then RETURN(2*w(i)+w(i+1)+1);
    else RETURN(2*w(i)+w(i+1)+2);
    fi; fi; end;
    # Then construct A160125:
    r := proc(n) option remember; local k,i;
    if (n<=2) then RETURN(0)
    elif (n <= 4) then RETURN(2)
    else
    k:=floor(log(n)/log(2)); i:=n-2^k;
    if (i=0) then RETURN(2^k-2)
    elif (i<=2^k-2) then RETURN(4*w(i));
    else RETURN(4*w(i)+2);
    fi; fi; end;
    [seq(r(n),n=0..200)];
    # N. J. A. Sloane, Feb 01 2010
  • Mathematica
    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]]];
    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]]];
    Array[r, 78] (* Jean-François Alcover, Apr 15 2020, from Maple *)

Formula

See Maple program for recurrence.

Extensions

Terms beyond a(10) from R. J. Mathar, Jan 21 2010