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.

Previous Showing 11-14 of 14 results.

A307269 Number of permutations p of [n] such that |p(i) - p(i-1)| is in {2,5} for all i from 2 to n.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 2, 14, 12, 8, 28, 58, 44, 120, 254, 226, 344, 932, 1262, 1380, 2958, 5006, 5632, 9496, 18204, 23756, 32758, 59992, 90494, 118740, 196318, 320814, 437270, 653770, 1077580, 1570054, 2233920, 3551168, 5426452, 7714408, 11709864
Offset: 0

Views

Author

Alois P. Heinz, Apr 01 2019

Keywords

Comments

For n>1, a(n)/2 is the number of Hamiltonian paths on the graph with vertex set {1,...,n} where i is adjacent to j iff |i-j| is in {2,5}.

Examples

			a(6) = 2: 246135, 531642.
a(7) = 14: 1357246, 1642753, 2461357, 2753164, 3164275, 3572461, 4275316, 4613572, 5316427, 5724613, 6135724, 6427531, 7246135, 7531642.
a(8) = 12: 13572468, 13864275, 16427538, 16835724, 42753168, 42753861, 57246138, 57246831, 83164275, 83572461, 86135724, 86427531.
a(9) = 8: 168357249, 168357942, 249753168, 249753861, 861357249, 861357942, 942753168, 942753861.
		

Crossrefs

Programs

  • Maple
    b:= proc(s, l) option remember; `if`(s={}, 1, add(
          `if`(abs(l-j) in {2, 5}, b(s minus {j}, j), 0), j=s))
        end:
    a:= proc(n) option remember; if n=0 then 1 else
          add(b({$1..n} minus {j}, j), j=1..n) fi
        end:
    seq(a(n), n=0..20);
  • Mathematica
    b[s_, l_] := b[s, l] = If[s == {}, 1, Sum[If[MemberQ[{2, 5}, Abs[l - j]], b[s ~Complement~ {j}, j], 0], {j, s}]];
    a[n_] := a[n] = If[n==0, 1, Sum[b[Range[n] ~Complement~ {j}, j], {j, n}]];
    Table[Print[n, " ", a[n]]; a[n], {n, 0, 27}] (* Jean-François Alcover, Oct 23 2021, after Alois P. Heinz *)

A328648 Number of permutations p of [n] such that |p(i) - p(i-1)| is in {2,7} for all i from 2 to n.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 0, 0, 2, 18, 12, 0, 12, 62, 76, 32, 44, 162, 600, 714, 386, 550, 2514, 5320, 4140, 3336, 8626, 24722, 33428, 27110, 34812, 96210, 200322, 220360, 213368, 376178, 894780, 1400578, 1473944, 1810538, 3653304, 7170370, 9467970
Offset: 0

Views

Author

Alois P. Heinz, Oct 23 2019

Keywords

Comments

For n>1, a(n)/2 is the number of Hamiltonian paths on the graph with vertex set {1,...,n} where i is adjacent to j iff |i-j| is in {2,7}.

Examples

			a(8) = 2: 24681357, 75318642.
a(9) = 18: 135792468, 186429753, 246813579, 297531864, 318642975, 357924681, 429753186, 468135792, 531864297, 579246813, 642975318, 681357924, 753186429, 792468135, 813579246, 864297531, 924681357, 975318642.
a(10) = 12: 135792468(10), 13(10)8642975, 186429753(10), 18(10)3579246, 579246813(10), 5792468(10)31, 642975318(10), 6429753(10)81, (10)318642975, (10)357924681, (10)813579246, (10)864297531.
		

Crossrefs

Programs

  • Maple
    b:= proc(s, l) option remember; `if`(s={}, 1, add(`if`(l=0
          or abs(l-j) in {2, 7}, b(s minus {j}, j), 0), j=s))
        end:
    a:= n-> b({$1..n}, 0):
    seq(a(n), n=0..20);
  • Mathematica
    b[s_, l_] := b[s, l] = If[s == {}, 1, Sum[If[l == 0 || MemberQ[{2, 7}, Abs[l - j]], b[s ~Complement~ {j}, j], 0], {j, s}]];
    a[n_] := b[Range[n], 0];
    Table[a[n], {n, 0, 25}] (* Jean-François Alcover, Oct 23 2021, after Alois P. Heinz *)

A187817 Number of permutations p of {1,...,n} such that exactly two elements of {p(1),...,p(i-1)} are between p(i) and p(i+1) for all i from 3 to n-1.

Original entry on oeis.org

1, 1, 2, 6, 4, 4, 4, 4, 8, 12, 20, 32, 52, 104, 188, 344, 616, 1116, 2232, 4236, 8084, 15212, 28760, 57520, 111512, 216804, 417560, 806440, 1612880, 3162132, 6209192, 12113136, 23670168, 47340336, 93411704, 184494460, 362693224, 713767712, 1427535424
Offset: 0

Views

Author

Alois P. Heinz, Oct 03 2013

Keywords

Examples

			a(4) = 4: 2314, 2341, 3214, 3241.
a(5) = 4: 23514, 32514, 34152, 43152.
a(6) = 4: 341625, 346152, 431625, 436152.
a(7) = 4: 3471625, 4371625, 4517263, 5417263.
a(8) = 8: 34716258, 43716258, 45182736, 45817263, 54182736, 54817263, 56283741, 65283741.
a(9) = 12: 348172596, 438172596, 451827369, 459182736, 541827369, 549182736, 561928374, 569283741, 651928374, 659283741, 672938514, 762938514.
		

Crossrefs

Programs

  • Maple
    b:= proc(u, o) option remember; `if`(u+o<3, (u+o)!,
          `if`(o>2, b(sort([o-3, u+2])[]), 0)+
          `if`(u>2, b(sort([u-3, o+2])[]), 0))
        end:
    a:= n-> `if`(n=0, 1, add(b(sort([j-1, n-j])[]), j=1..n)):
    seq(a(n), n=0..40);
  • Mathematica
    b[u_, o_] := b[u, o] = If[u + o < 3, (u + o)!,
         If[o > 2, b @@ Sort[{o - 3, u + 2}], 0] +
         If[u > 2, b @@ Sort[{u - 3, o + 2}], 0]];
    a[n_] := If[n == 0, 1, Sum[b @@ Sort[{j - 1, n - j}], {j, 1, n}]];
    a /@ Range[0, 40] (* Jean-François Alcover, Mar 15 2021, after Alois P. Heinz *)

A249631 Number of permutations p of {1,...,n} such that |p(i+1)-p(i)| < k, k=2,...,n; T(n,k), read by rows.

Original entry on oeis.org

2, 2, 6, 2, 12, 24, 2, 20, 72, 120, 2, 34, 180, 480, 720, 2, 56, 428, 1632, 3600, 5040, 2, 88, 1042, 5124, 15600, 30240, 40320, 2, 136, 2512, 15860, 61872, 159840, 282240, 362880, 2, 208, 5912, 50186, 236388, 773040, 1764000, 2903040, 3628800
Offset: 2

Views

Author

Li-yao Xia, Nov 02 2014

Keywords

Examples

			Triangle starts with n=2:
2;
2,  6;
2, 12,  24;
2, 20,  72, 120;
2, 34, 180, 480, 720;
		

Crossrefs

Cf. A000142, main diagonal, A062119, subdiagonal.
Cf. A003274, A174700, A174701, A174702, 2nd to 5th columns, T(n,k), k=3,4,5,6.
Cf. A174703, A174704, A174705, A174706, A174707, A174708, similar definitions.

Programs

  • Haskell
    a n x = filter (\l -> all (< x) (zipWith (\x y -> abs (x - y)) l (tail l))) (permutations [1 .. n])
    
  • PARI
    isokp(perm, k) = {for (i=1, #perm-1, if (abs(perm[i]-perm[i+1]) >= k, return (0));); return (1);}
    tabl(nn) = {for (n=2, nn, for (k=2, n, print1(sum(i=1, n!, isokp(numtoperm(n, i), k)), ", ");); print(););} \\ Michel Marcus, Nov 06 2014
Previous Showing 11-14 of 14 results.