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.

A006851 Trails of length n on honeycomb lattice.

Original entry on oeis.org

1, 3, 6, 12, 24, 48, 96, 186, 360, 696, 1344, 2562, 4872, 9288, 17664, 33384, 63120, 119280, 225072, 423630, 797400, 1499256, 2817216, 5286480, 9918768, 18592080, 34840848, 65228874, 122105496, 228402168, 427176336, 798373662, 1491985800, 2786515176, 5203816992, 9712725234, 18127267800
Offset: 0

Views

Author

Keywords

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A001668.

Programs

  • Maple
    a:= proc(n) option remember; local v, b;
          if n<2 then return 1 +2*n fi;
          v:= proc() false end: v(1, 0):= true;
          b:= proc(n, d, x, y) local c;
                if v(x, y) then `if`(n>0 or [x, y, d]=[1, 0, 1], 0, 1)
              elif n=0 then 1
              else v(x, y):= true;
                   c:= b(n-1, [$2..6, 1][d], x+[0, -1, -1, 0, 1, 1][d],
                                             y+[1, 1, 0, -1, -1, 0][d])+
                       b(n-1, [6, $1..5][d], x+[1, 1, 0, -1, -1, 0][d],
                                             y+[-1, 0, 1, 1, 0, -1][d]);
                   v(x, y):= false; c
                fi
              end;
          6*b(n-2, 2, 1, 1)
        end:
    seq(a(n), n=0..20);  # Alois P. Heinz, Jul 08 2011
  • Mathematica
    a[n_] := a[n] = Module[{v, b}, If[n<2, Return[1+2*n]]; v[, ] = False; v[1, 0] = True; b[n0_, d_, x_, y_] := Module[{c}, Which[v[x, y], If[n0>0 || {x, y, d} == {1, 0, 1}, 0, 1], n0 == 0, 1, True, v[x, y] = True; c = b[n0-1, {2, 3, 4, 5, 6, 1}[[d]], x+{0, -1, -1, 0, 1, 1}[[d]], y+{1, 1, 0, -1, -1, 0}[[d]]] + b[n0-1, {6, 1, 2, 3, 4, 5}[[d]], x+{1, 1, 0, -1, -1, 0}[[d]], y+{-1, 0, 1, 1, 0, -1}[[d]]]; v[x, y] = False; c]]; 6*b[n-2, 2, 1, 1]]; Table[Print[a[n]]; a[n], {n, 0, 25}] (* Jean-François Alcover, Mar 20 2014, after Alois P. Heinz *)