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.

A007974 Number of permutations that are n-3 "block reversals" away from 12...n.

Original entry on oeis.org

1, 6, 52, 389, 2539, 16604, 105365, 654030, 3900116, 22073230, 116855950, 567965207
Offset: 3

Views

Author

Keywords

Crossrefs

Programs

  • Python
    def a(n):
        perm = tuple(range(1, n+1)); reach = {perm}; frontier = {perm}
        for k in range(n-3):
            r1 = set()
            while len(frontier) > 0:
                q = frontier.pop()
                for i in range(n):
                    for j in range(i+1, n+1):
                        qp = list(q)
                        qp[i:j] = qp[i:j][::-1]
                        qp = tuple(qp)
                        if qp not in reach:
                            reach.add(qp)
                            r1.add(qp)
            frontier = r1
        return len(frontier)
    print([a(n) for n in range(3, 10)]) # Michael S. Branicky, Jan 26 2023

Formula

a(n) = A300003(n,n-3).

Extensions

a(9)-a(11) from Sean A. Irvine, Feb 22 2018
a(12) from Thomas Baruchel, Mar 26 2025
a(13)-a(14) from Bert Dobbelaere, Apr 12 2025