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-2 of 2 results.

A227413 a(1)=1, a(2n)=nthprime(a(n)), a(2n+1)=nthcomposite(a(n)), where nthprime = A000040, nthcomposite = A002808.

Original entry on oeis.org

1, 2, 4, 3, 6, 7, 9, 5, 8, 13, 12, 17, 14, 23, 16, 11, 10, 19, 15, 41, 22, 37, 21, 59, 27, 43, 24, 83, 35, 53, 26, 31, 20, 29, 18, 67, 30, 47, 25, 179, 58, 79, 34, 157, 54, 73, 33, 277, 82, 103, 40, 191, 62, 89, 36, 431, 114, 149, 51, 241, 75, 101, 39, 127, 46
Offset: 1

Views

Author

Antti Karttunen, Jul 10 2013

Keywords

Comments

Inverse permutation of A135141.
Shares with A073846 the property that the other bisection consists of just primes and the other bisection of just nonprimes.

Crossrefs

Similarly constructed permutations: A227402, A227404, A227410, A227412. Cf. also A073846, A209636.

Programs

  • Haskell
    import Data.List (transpose)
    a227413 n = a227413_list !! (n-1)
    a227413_list = 1 : concat (transpose [map a000040 a227413_list,
                                          map a002808 a227413_list])
    -- Reinhard Zumkeller, Jan 29 2014

Formula

a(1)=1, a(2n) = A000040(a(n)), a(2n+1) = A002808(a(n)).
A007097(n) = a(A000079(n)).

A216239 Total number of inversions in all derangement permutations of [n].

Original entry on oeis.org

0, 0, 1, 4, 34, 260, 2275, 21784, 228676, 2614296, 32372805, 431971100, 6182204006, 94495208444, 1536740258599, 26498747241680, 482990781797000, 9279452377499504, 187442757190618761, 3971627425918503156, 88084356619901450410, 2040857112777615061300
Offset: 0

Views

Author

Alois P. Heinz, Mar 15 2013

Keywords

Examples

			a(2) = 1: (2,1) has 1 inversion.
a(3) = 4: (2,3,1), (3,1,2) have 2+2 = 4 inversions.
a(4) = 34: (2,1,4,3), (2,3,4,1), (2,4,1,3), (3,1,4,2), (3,4,1,2), (3,4,2,1), (4,1,2,3), (4,3,1,2), (4,3,2,1) have 2+3+3+3+4+5+3+5+6 = 34 inversions.
		

Crossrefs

Programs

  • Maple
    v:= proc(l) local i; for i to nops(l) do if l[i]=i then return 0 fi od;
          add(add(`if`(l[i]>l[j], 1, 0), j=i+1..nops(l)), i=1..nops(l)-1)
        end:
    a:= n-> add(v(d), d=combinat[permute](n)):
    seq(a(n), n=0..8);
    # second Maple program:
    a:= proc(n) option remember; `if`(n<3, n*(n-1)/2,
          n*((6*n^3-26*n^2+31*n-9)*a(n-1)+(n-1)*
          (6*n^2-8*n+1)*a(n-2))/((n-2)*(15-20*n+6*n^2)))
        end:
    seq(a(n), n=0..25);  # Alois P. Heinz, Aug 13 2013
  • Mathematica
    A216239[n_] := (1/12)*n*(3*(-1)^n*n + (n*(3*n - 1) + 1)*Subfactorial[n-1]); Table[a[n], {n, 0, 21}] (* Jean-François Alcover, Feb 05 2015, after Max Alekseyev *)
  • PARI
    A216239(n) = sum(k=0,n-2, (-1)^k * n!/k! * (3*n+k) * (n-k-1) )/12; /* Max Alekseyev, Aug 13 2013 */

Formula

a(n) = SUM(k=0..n-2, (-1)^k * n!/k! * (3*n+k)*(n-k-1) )/12. - Max Alekseyev, Aug 13 2013
a(n) = ( (3*n^2-n+1)*A000166(n) + (n-1)*(-1)^n )/12. - Max Alekseyev, Aug 14 2013
a(n) = Sum_{k>=1} A228924(n,k) * k. - Alois P. Heinz, Sep 22 2013
a(n) ~ n! * n^2 / (4*exp(1)). - Vaclav Kotesovec, Sep 10 2014

Extensions

Formula and terms a(15) onward from Max Alekseyev, Aug 13 2013
Showing 1-2 of 2 results.