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.

A127697 Number of permutations of {1,2,...,n} where adjacent elements differ in value by 3 or more.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 2, 32, 368, 3984, 44304, 521606, 6564318, 88422296, 1272704694, 19521035238, 318120059458, 5491779703870, 100150978723568, 1924351621839740, 38864316540425434, 823161467837784388
Offset: 0

Views

Author

Richard Forster (gbrl01(AT)yahoo.co.uk), Apr 11 2007, Apr 26 2007

Keywords

Comments

Equivalently, number of permutations of {1,2,...,n} where elements that differ by 1 in value are neither in positions i and i+1 (adjacent), nor i and i+2.

Examples

			Valid permutations of {1,...,6} are 415263 and 362514.
		

Crossrefs

Cf. A002464 (stride >= 2), A179957 (stride >= 4), A179958 (stride >=5).

Programs

  • Mathematica
    Clear[permCount]; permCount[s_, last_] := permCount[s, last] = Module[{n, j}, n = Length[s]; If[n == 0, 1, Total[Table[If[Abs[last - j] >= 3, permCount[DeleteCases[s, j], j], 0], {j, s}]]]]; Table[permCount[Range[n], -2], {n, 0, 12}] (* Robert P. P. McKone, Mar 01 2025 *)

Extensions

Jul 01 2010: Zak Seidov corrected a(10) and a(11). R. H. Hardin then computed a(12) through a(18).
Corrected first term to 1 (was 0).
a(0), a(19)-a(20) from Alois P. Heinz, Oct 27 2014
a(21) from Alois P. Heinz, Feb 09 2025

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

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

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 0, 0, 1, 16, 272, 2880, 32648, 333696, 3617545, 38942336, 443291226, 5168682752, 63523977424, 807890646528, 10790865576074, 149552304296960, 2168856599259491, 32631738808727552, 512002155247238968
Offset: 0

Views

Author

R. J. Mathar, Oct 27 2014

Keywords

Crossrefs

Cf. A245377 (at least 2), A249390 (at least 3), A249392-A249393, A179957 (non-alternating).

Extensions

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

A322281 Number of permutations sigma such that |sigma(i+j)-sigma(i)| >= 4 for 1 <= i <= n - j, 1 <= j <= 3.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 2424, 93424, 4394386, 201355480
Offset: 0

Views

Author

Seiichi Manyama, Dec 01 2018

Keywords

Comments

2 | a(n) for n > 1.

Examples

			a(16) = 2: [4,8,12,16,3,7,11,15,2,6,10,14,1,5,9,13] and its reverse.
		

Crossrefs

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 A322281(n)
      (0..n).map{|i| solve(4, i).size}
    end
    p A322281(18)

Extensions

a(21) from Alois P. Heinz, Dec 02 2018

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.