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.

Showing 1-5 of 5 results.

A363181 Number of permutations p of [n] such that for each i in [n] we have: (i>1) and |p(i)-p(i-1)| = 1 or (i

Original entry on oeis.org

1, 0, 2, 2, 8, 14, 54, 128, 498, 1426, 5736, 18814, 78886, 287296, 1258018, 4986402, 22789000, 96966318, 461790998, 2088374592, 10343408786, 49343711666, 253644381032, 1268995609502, 6756470362374, 35285321738624, 194220286045506, 1054759508543554
Offset: 0

Views

Author

Alois P. Heinz, May 19 2023

Keywords

Comments

Number of permutations p of [n] such that each element in p has at least one neighbor whose value is smaller or larger by one.
Number of permutations of [n] having n occurrences of the 1-box pattern.

Examples

			a(0) = 1: (), the empty permutation.
a(1) = 0.
a(2) = 2: 12, 21.
a(3) = 2: 123, 321.
a(4) = 8: 1234, 1243, 2134, 2143, 3412, 3421, 4312, 4321.
a(5) = 14: 12345, 12354, 12543, 21345, 21543, 32145, 32154, 34512, 34521, 45123, 45321, 54123, 54312, 54321.
a(6) = 54: 123456, 123465, 123654, 124356, 124365, 125634, 125643, 126534, 126543, 213456, 213465, 214356, 214365, 215634, 215643, 216534, 216543, 321456, 321654, 341256, 341265, 342156, 342165, 345612, 345621, 346512, 346521, 431256, 431265, 432156, 432165, 435612, 435621, 436512, 436521, 456123, 456321, 561234, 561243, 562134, 562143, 563412, 563421, 564312, 564321, 651234, 651243, 652134, 652143, 653412, 653421, 654123, 654312, 654321.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n<4, [1, 0, 2$2][n+1],
          3/2*a(n-1)+(n-3/2)*a(n-2)-(n-5/2)*a(n-3)+(n-4)*a(n-4))
        end:
    seq(a(n), n=0..30);

Formula

a(n) = A346462(n,n).
a(n)/2 mod 2 = A011655(n-1) for n>=1.
a(n) ~ sqrt(Pi) * n^((n+1)/2) / (2 * exp(n/2 - sqrt(n)/2 + 7/16)) * (1 - 119/(192*sqrt(n))). - Vaclav Kotesovec, May 26 2023

A279214 Number of permutations sigma such that |sigma(i+1)-sigma(i)| >= 3 for 1 <= i <= n - 1 and |sigma(i+2)-sigma(i)| >= 3 for 1 <= i <= n - 2.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 0, 0, 0, 2, 40, 792, 15374, 281434, 5089060, 93082532, 1743601076, 33694028152
Offset: 0

Views

Author

Seiichi Manyama, Dec 17 2016

Keywords

Comments

2 | a(n) for n > 1.

Examples

			a(9) = 2: 369258147, 741852963.
		

Crossrefs

Cf. A002464 (|sigma(i+1)-sigma(i)| >= 2), A127697 (|sigma(i+1)-sigma(i)| >= 3).

Programs

  • Ruby
    def check(d, a, i)
      return true if i == 0
      j = 1
      d_max = [i, d - 1].min
      while (a[i] - a[i - j]).abs >= d && j < d_max
        j += 1
      end
      (a[i] - a[i - j]).abs >= d
    end
    def solve(d, len, a = [])
      b = []
      if a.size == len
        b << a
      else
        (1..len).each{|m|
          s = a.size
          if s == 0 || (s > 0 && !a.include?(m))
            if check(d, a + [m], s)
              b += solve(d, len, a + [m])
            end
          end
        }
      end
      b
    end
    def A279214(n)
      (0..n).map{|i| solve(3, i).size}
    end
    p A279214(12)

Extensions

a(0)-a(2), a(15)-a(17) from Alois P. Heinz, Dec 01 2018

A249390 The number of down-up permutations of [n] where adjacent elements differ by at least 3.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 1, 8, 68, 480, 3637, 27968, 231410, 2014784, 18789010, 185234176, 1943243785, 21501237248, 251589065328, 3093350098432, 40007001803593, 541652523341824, 7679190979467688, 113578314941202432
Offset: 0

Views

Author

R. J. Mathar, Oct 27 2014

Keywords

Crossrefs

Cf. A245377 (at least 2), A249391, A249392, A249393, A127697 (non-alternating).

Extensions

a(17)-a(20) from Alois P. Heinz, Oct 27 2014
a(21) from Alois P. Heinz, Oct 28 2014
a(22)-a(23) from Max Alekseyev, Feb 20 2024

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 *)

A322255 Triangle T(n,k) giving the number of permutations of 1..n with no adjacent elements within k in value, for n >= 2, 1 <= k <= floor(n/2).

Original entry on oeis.org

2, 6, 24, 2, 120, 14, 720, 90, 2, 5040, 646, 32, 40320, 5242, 368, 2, 362880, 47622, 3984, 72, 3628800, 479306, 44304, 1496, 2, 39916800, 5296790, 521606, 25384, 160, 479001600, 63779034, 6564318, 399848, 6056, 2, 6227020800, 831283558, 88422296, 6231544, 161136, 352
Offset: 2

Views

Author

Seiichi Manyama, Dec 01 2018

Keywords

Examples

			Irregular triangle starts:
n\k|       1       2      3     4  5
---+---------------------------------
2  |       2;
3  |       6;
4  |      24,      2;
5  |     120,     14;
6  |     720,     90,     2;
7  |    5040,    646,    32;
8  |   40320,   5242,   368,    2;
9  |  362880,  47622,  3984,   72;
10 | 3628800, 479306, 44304, 1496, 2;
		

Crossrefs

Formula

T(n,k) = Sum_{j=k..floor(n/2)} A129534(n,j). - Alois P. Heinz, May 20 2023
Showing 1-5 of 5 results.