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.

A381461 Number of permutations of [n] with no fixed points where adjacent elements differ by at least 3.

Original entry on oeis.org

1, 0, 0, 0, 0, 0, 2, 8, 115, 1274, 15099, 179628, 2260064, 30534802, 441269110, 6789665680, 110947884520, 1920180939650, 35099424286573, 675866037989156, 13676799446869485, 290208293166279344, 6443880771921767240
Offset: 0

Views

Author

Alois P. Heinz, Feb 24 2025

Keywords

Examples

			a(6) = 2: 362514, 415263.
a(7) = 8: 2516374, 3615274, 3625174, 3627415, 3741625, 4152736, 4163725, 4173625.
a(8) = 115: 25163847, 25174836, 25184736, 25814736, ..., 84736251, 85263714, 85263741, 85274163.
		

Crossrefs

Programs

  • Maple
    b:= proc(s, l) option remember; (n-> `if`(n=0, 1, add(
         `if`(j=n or abs(l-j)<3, 0, b(s minus {j}, j)), j=s)))(nops(s))
        end:
    a:= n-> b({$1..n}, -2):
    seq(a(n), n=0..16);
  • Mathematica
    Clear[permCount]; permCount[s_, last_] := permCount[s, last] = Module[{n, j}, n = Length[s]; If[n == 0, 1, Total[Table[If[j == n || Abs[last - j] < 3, 0, permCount[Complement[s, {j}], j]], {j, s}]]]]; Table[permCount[Range[n], -2], {n, 0, 12}] (* Robert P. P. McKone, Mar 01 2025 *)