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.

A005165 Alternating factorials: n! - (n-1)! + (n-2)! - ... 1!.

Original entry on oeis.org

0, 1, 1, 5, 19, 101, 619, 4421, 35899, 326981, 3301819, 36614981, 442386619, 5784634181, 81393657019, 1226280710981, 19696509177019, 335990918918981, 6066382786809019, 115578717622022981, 2317323290554617019, 48773618881154822981
Offset: 0

Views

Author

Keywords

Comments

Conjecture: for n > 2, smallest prime divisor of a(n) > n. - Gerald McGarvey, Jun 19 2004
Rebuttal: This is not true; see Zivkovic link (Math. Comp. 68 (1999), pp. 403-409) has demonstrated that 3612703 divides a(n) for all n >= 3612702. - Paul Jobling, Oct 18 2004
Conjecture: For n>1, a(n) is the number of lattice paths from (0,0) to (n+1,0) that do not cross above y=x or below the x-axis using up-steps +(1,a) and down-steps +(1,-b) where a and b are positive integers. For example, a(3) = 5: [(1,1)(1,1)(1,1)(1,-3)], [(1,1)(1,-1)(1,3)(1,-3)], [(1,1)(1,-1)(1,2)(1,-2)], [(1,1)(1,-1)(1,1)(1,-1)] and [(1,1)(1,1)(1,-1)(1,-1)]. - Nicholas Ham, Aug 23 2015
Ham's claim is true for n=2. We proceed with a proof for n>2 by induction. On the j-th step, from (j-1,y) to (j,y'), there are j options for y': 0, 1, ..., y-1, y+1, ..., j. Thus there are n! possible paths from (0,0) to x=n that stay between y=0 and y=x. (Then the final step is determined.) However, because +(1,0) is not an allowable step, we cannot land on (n,0) on the n-th step. Therefore, the number of acceptable lattice paths is n! - a(n-1). - Danny Rorabaugh, Nov 30 2015

References

  • Richard K. Guy, Unsolved Problems in Number Theory, 3rd Edition, Springer, 2004, Section B10, pp. 152-153.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • GAP
    List([0..30],n->Sum([1..n],i->(-1)^(n-i)*Factorial(i))); # Muniru A Asiru, Jun 01 2018
  • Haskell
    a005165 n = a005165_list !! n
    a005165_list = 0 : zipWith (-) (tail a000142_list) a005165_list
    -- Reinhard Zumkeller, Jul 21 2013
    
  • Maple
    A005165 := proc(n) local i; add((-1)^(n-i)*i!,i=1..n); end;
  • Mathematica
    nn=25;With[{fctrls=Range[nn]!},Table[Abs[Total[Times@@@Partition[ Riffle[ Take[ fctrls,n],{1,-1}],2]]],{n,nn}]] (* Harvey P. Dale, Dec 10 2011 *)
    a[0] = 0; a[n_] := n! - a[n - 1]; Array[a, 26, 0] (* Robert G. Wilson v, Aug 06 2012 *)
    RecurrenceTable[{a[n] == n! - a[n - 1], a[0] == 0}, a, {n, 0, 20}] (* Eric W. Weisstein, Jul 27 2017 *)
    AlternatingFactorial[Range[0, 20]] (* Eric W. Weisstein, Jul 27 2017 *)
    a[n_] = (-1)^n (Exp[1]((-1)^n Gamma[-1-n,1] Gamma[2+n] - ExpIntegralEi[-1]) - 1)
    Table[a[n] // FullSimplify, {n, 0, 20}] (* Gerry Martens, May 22 2018 *)
  • PARI
    a(n)=if(n<0,0,sum(k=0,n-1,(-1)^k*(n-k)!))
    
  • PARI
    first(m)=vector(m,j,sum(i=0,j-1,((-1)^i)*(j-i)!)) \\ Anders Hellström, Aug 23 2015
    
  • PARI
    a(n)=round((-1)^n*(exp(1)*(gamma(n+2)*incgam(-1-n,1)*(-1)^n +eint1(1))-1)) \\ Gerry Martens, May 22 2018
    
  • Python
    a = 0
    f = 1
    for n in range(1, 33):
        print(a, end=",")
        f *= n
        a = f - a
    # Alex Ratushnyak, Aug 05 2012
    

Formula

a(0) = 0, a(n) = n! - a(n-1) for n > 0; also a(n) = n*a(n-2) + (n-1)*a(n-1) for n > 1. Sum_{n>=1} Pi^n/a(n) ~ 30.00005. - Gerald McGarvey, Jun 19 2004
E.g.f.: 1/(1-x) + exp(-x)*(e*(Ei(1,1)-Ei(1,1-x)) - 1). - Robert Israel, Dec 01 2015
a(n) = (-1)^n*(exp(1)*(gamma(n+2)*gamma(-1-n,1)*(-1)^n +Ei(1))-1). - Gerry Martens, May 22 2018
Sum_{n>=1} 1/a(n) = A343187. - Amiram Eldar, Jun 01 2023

A153229 a(0) = 0, a(1) = 1, and for n >= 2, a(n) = (n-1) * a(n-2) + (n-2) * a(n-1).

Original entry on oeis.org

0, 1, 0, 2, 4, 20, 100, 620, 4420, 35900, 326980, 3301820, 36614980, 442386620, 5784634180, 81393657020, 1226280710980, 19696509177020, 335990918918980, 6066382786809020, 115578717622022980, 2317323290554617020, 48773618881154822980, 1075227108896452857020
Offset: 0

Views

Author

Shaojun Ying (dolphinysj(AT)gmail.com), Dec 21 2008

Keywords

Comments

Previous name was: Weighted Fibonacci numbers.
From Peter Bala, Aug 18 2013: (Start)
The sequence occurs in the evaluation of the integral I(n) := Integral_{u >= 0} exp(-u)*u^n/(1 + u) du.
The result is I(n) = A153229(n) + (-1)^n*I(0), where I(0) = Integral_{u >= 0} exp(-u)/(1 + u) du = 0.5963473623... is known as Gompertz's constant. See A073003.
Note also that I(n) = n!*Integral_{u >= 0} exp(-u)/(1 + u)^(n+1) du. (End)
((-1)^(n+1))*a(n) = p(n,-1), where the polynomials p are defined at A248664. - Clark Kimberling, Oct 11 2014

Examples

			a(20) = 19 * a(18) + 18 * a(19) = 19 * 335990918918980 + 18 * 6066382786809020 = 6383827459460620 + 109194890162562360 = 115578717622022980
		

Crossrefs

First differences of A136580.
Column k=0 of A303697 (for n>0).

Programs

  • C
    unsigned long a(unsigned int n) {
    if (n == 0) return 0;
    if (n == 1) return 1;
    return (n - 1) * a(n - 2) + (n - 2) * a(n - 1); }
    
  • Maple
    t1 := sum(n!*x^n, n=0..100): F := series(t1/(1+x), x, 100): for i from 0 to 40 do printf(`%d, `, i!-coeff(F, x, i)) od: # Zerinvary Lajos, Mar 22 2009
    # second Maple program:
    a:= proc(n) a(n):= `if`(n<2, n, (n-1)*a(n-2) +(n-2)*a(n-1)) end:
    seq(a(n), n=0..25); # Alois P. Heinz, May 24 2013
  • Mathematica
    Join[{a = 0}, Table[b = n! - a; a = b, {n, 0, 100}]] (* Vladimir Joseph Stephan Orlovsky, Jun 28 2011 *)
    RecurrenceTable[{a[0]==0,a[1]==1,a[n]==(n-1)a[n-2]+(n-2)a[n-1]},a,{n,30}] (* Harvey P. Dale, May 01 2020 *)
  • PARI
    a(n)=if(n,my(t=(-1)^n);-t-sum(i=1,n-1,t*=-i),0); \\ Charles R Greathouse IV, Jun 28 2011

Formula

a(0) = 0, a(1) = 1, and for n >= 2, a(n) = (n-1) * a(n-2) + (n-2) * a(n-1).
For n>=1, a(n) = A058006(n-1) * (-1)^(n-1).
G.f.: G(0)*x/(1+x)/2, where G(k)= 1 + 1/(1 - x*(k+1)/(x*(k+1) + 1/G(k+1))); (continued fraction). - Sergei N. Gladkovskii, May 24 2013
G.f.: 2*x/(1+x)/G(0), where G(k)= 1 + 1/(1 - 1/(1 - 1/(2*x*(k+1)) + 1/G(k+1))); (continued fraction). - Sergei N. Gladkovskii, May 29 2013
G.f.: W(0)*x/(1+sqrt(x))/(1+x), where W(k) = 1 + sqrt(x)/( 1 - sqrt(x)*(k+1)/(sqrt(x)*(k+1) + 1/W(k+1) )); (continued fraction). - Sergei N. Gladkovskii, Aug 17 2013
a(n) ~ (n-1)! * (1 - 1/n + 1/n^3 + 1/n^4 - 2/n^5 - 9/n^6 - 9/n^7 + 50/n^8 + 267/n^9 + 413/n^10), where numerators are Rao Uppuluri-Carpenter numbers, see A000587. - Vaclav Kotesovec, Mar 16 2015
E.g.f.: exp(1)/exp(x)*(Ei(1, 1-x)-Ei(1, 1)). - Alois P. Heinz, Jul 05 2018
a(n) = Sum_{k = 0..n-1} (-1)^(n-k-1) * k!. - Peter Bala, Dec 05 2024

Extensions

Edited by Max Alekseyev, Jul 05 2010
Better name by Joerg Arndt, Aug 17 2013

A321316 Number T(n,k) of permutations of [n] whose difference between the length of the longest increasing subsequence and the length of the longest decreasing subsequence equals k; triangle T(n,k), n >= 1, 1-n <= k <= n-1, read by rows.

Original entry on oeis.org

1, 1, 0, 1, 1, 0, 4, 0, 1, 1, 0, 9, 4, 9, 0, 1, 1, 0, 16, 25, 36, 25, 16, 0, 1, 1, 0, 25, 81, 125, 256, 125, 81, 25, 0, 1, 1, 0, 36, 196, 421, 1225, 1282, 1225, 421, 196, 36, 0, 1, 1, 0, 49, 400, 1225, 4292, 9261, 9864, 9261, 4292, 1225, 400, 49, 0, 1
Offset: 1

Views

Author

Alois P. Heinz, Nov 03 2018

Keywords

Examples

			:                                1                             ;
:                          1,    0,    1                       ;
:                    1,    0,    4,    0,   1                  ;
:               1,   0,    9,    4,    9,   0,   1             ;
:          1,   0,  16,   25,   36,   25,  16,   0,  1         ;
:      1,  0,  25,  81,  125,  256,  125,  81,  25,  0, 1      ;
:   1, 0, 36, 196, 421, 1225, 1282, 1225, 421, 196, 36, 0, 1   ;
		

Crossrefs

Column k=0 gives A321313.
Row sums give A000142.
T(n+1,n-2) gives A000290.

Programs

  • Maple
    h:= l-> (n-> add(i, i=l)!/mul(mul(1+l[i]-j+add(`if`(j>
        l[k], 0, 1), k=i+1..n), j=1..l[i]), i=1..n))(nops(l)):
    f:= l-> h(l)^2*x^(l[1]-nops(l)) :
    g:= (n, i, l)-> `if`(n=0 or i=1, f([l[], 1$n]),
         g(n, i-1, l) +g(n-i, min(i, n-i), [l[], i])):
    b:= proc(n) option remember; g(n$2, []) end:
    T:= (n, k)-> coeff(b(n), x, k):
    seq(seq(T(n, k), k=1-n..n-1), n=1..10);
  • Mathematica
    h[l_] := With[{n = Length[l]}, Total[l]!/Product[Product[1 + l[[i]] - j + Sum[If[j > l[[k]], 0, 1], {k, i + 1, n}], {j, 1, l[[i]]}], {i, 1, n}]];
    f[l_] := h[l]^2*x^(l[[1]] - Length[l]);
    g[n_, i_, l_] := If[n == 0 || i == 1, f[Join[l, Table[1, {n}]]], g[n, i - 1, l] + g[n - i, Min[i, n - i], Append[l, i]]];
    b[n_] := b[n] = g[n, n, {}];
    T[n_, k_] := Coefficient[b[n], x, k];
    Table[Table[T[n, k], {k, 1 - n, n - 1}], {n, 1, 10}] // Flatten (* Jean-François Alcover, Feb 27 2021, after Alois P. Heinz *)

Formula

T(n,k) = T(n,-k).
Sum_{k=1..n-1} T(n,k) = A321314(n).
Sum_{k=0..n-1} T(n,k) = A321315(n).
(1/2) * Sum_{k=1-n..n-1} abs(k) * T(n,k) = A321277(n).
(1/2) * Sum_{k=1-n..n-1} k^2 * T(n,k) = A321278(n).

A316292 Number T(n,k) of permutations p of [n] such that k is the maximum of the partial sums of the signed up-down jump sequence of 0,p; triangle T(n,k), n>=0, ceiling((sqrt(1+8*n)-1)/2)<=k<=n, read by rows.

Original entry on oeis.org

1, 1, 2, 1, 5, 8, 16, 5, 50, 65, 1, 79, 314, 326, 69, 872, 2142, 1957, 34, 1539, 8799, 16248, 13700, 9, 1823, 24818, 89273, 137356, 109601, 1, 1494, 50561, 355271, 947713, 1287350, 986410, 856, 76944, 1070455, 4923428, 10699558, 13281458, 9864101
Offset: 0

Views

Author

Alois P. Heinz, Jun 28 2018

Keywords

Comments

An up-jump j occurs at position i in p if p_{i} > p_{i-1} and j is the index of p_i in the increasingly sorted list of those elements in {p_{i}, ..., p_{n}} that are larger than p_{i-1}. A down-jump -j occurs at position i in p if p_{i} < p_{i-1} and j is the index of p_i in the decreasingly sorted list of those elements in {p_{i}, ..., p_{n}} that are smaller than p_{i-1}. First index in the lists is 1 here.

Examples

			Triangle T(n,k) begins:
: 1;
:    1;
:       2;
:       1, 5;
:          8, 16;
:          5, 50,   65;
:          1, 79,  314,   326;
:             69,  872,  2142,   1957;
:             34, 1539,  8799,  16248,  13700;
:              9, 1823, 24818,  89273, 137356,  109601;
:              1, 1494, 50561, 355271, 947713, 1287350, 986410;
		

Crossrefs

Row sums give A000142.
Column sums give A316294.
Main diagonal gives A000522.
Cf. A002024, A123578, A258829, A291722, A303697, A316293 (same read by columns).

Programs

  • Maple
    b:= proc(u, o, c, k) option remember;
          `if`(c>k, 0, `if`(u+o=0, 1,
           add(b(u-j, o-1+j, c+j, k), j=1..u)+
           add(b(u+j-1, o-j, c-j, k), j=1..o)))
        end:
    T:= (n, k)-> b(n, 0$2, k) -`if`(k=0, 0, b(n, 0$2, k-1)):
    seq(seq(T(n, k), k=ceil((sqrt(1+8*n)-1)/2)..n), n=0..14);
  • Mathematica
    b[u_, o_, c_, k_] := b[u, o, c, k] =
         If[c > k, 0, If[u + o == 0, 1,
         Sum[b[u - j, o - 1 + j, c + j, k], {j, 1, u}] +
         Sum[b[u + j - 1, o - j, c - j, k], {j, 1, o}]]];
    T[n_, k_] := b[n, 0, 0, k] - If[k == 0, 0, b[n, 0, 0, k - 1]];
    Table[Table[T[n, k], {k, Ceiling[(Sqrt[8n+1]-1)/2], n}], {n, 0, 14}] // Flatten (* Jean-François Alcover, Feb 27 2021, after Alois P. Heinz *)

A316293 Number T(n,k) of permutations p of [n] such that k is the maximum of the partial sums of the signed up-down jump sequence of 0,p; triangle T(n,k), k>=0, k<=n<=k*(k+1)/2, read by columns.

Original entry on oeis.org

1, 1, 2, 1, 5, 8, 5, 1, 16, 50, 79, 69, 34, 9, 1, 65, 314, 872, 1539, 1823, 1494, 856, 339, 89, 14, 1, 326, 2142, 8799, 24818, 50561, 76944, 89546, 80938, 57284, 31771, 13707, 4520, 1103, 188, 20, 1, 1957, 16248, 89273, 355271, 1070455, 2514044, 4705648
Offset: 0

Views

Author

Alois P. Heinz, Jun 28 2018

Keywords

Comments

An up-jump j occurs at position i in p if p_{i} > p_{i-1} and j is the index of p_i in the increasingly sorted list of those elements in {p_{i}, ..., p_{n}} that are larger than p_{i-1}. A down-jump -j occurs at position i in p if p_{i} < p_{i-1} and j is the index of p_i in the decreasingly sorted list of those elements in {p_{i}, ..., p_{n}} that are smaller than p_{i-1}. First index in the lists is 1 here.

Examples

			Triangle T(n,k) begins:
: 1;
:    1;
:       2;
:       1, 5;
:          8, 16;
:          5, 50,   65;
:          1, 79,  314,   326;
:             69,  872,  2142,   1957;
:             34, 1539,  8799,  16248,  13700;
:              9, 1823, 24818,  89273, 137356,  109601;
:              1, 1494, 50561, 355271, 947713, 1287350, 986410;
		

Crossrefs

Row sums give A000142.
Column sums give A316294.
Main diagonal gives A000522.
Cf. A000217, A258829, A291722, A303697, A316292 (same read by rows).

Programs

  • Maple
    b:= proc(u, o, c, k) option remember;
          `if`(c>k, 0, `if`(u+o=0, 1,
           add(b(u-j, o-1+j, c+j, k), j=1..u)+
           add(b(u+j-1, o-j, c-j, k), j=1..o)))
        end:
    T:= (n, k)-> b(n, 0$2, k) -`if`(k=0, 0, b(n, 0$2, k-1)):
    seq(seq(T(n, k), n=k..k*(k+1)/2), k=0..8);
  • Mathematica
    b[u_, o_, c_, k_] := b[u, o, c, k] = If[c > k, 0, If[u + o == 0, 1,
         Sum[b[u - j, o - 1 + j, c + j, k], {j, 1, u}] +
         Sum[b[u + j - 1, o - j, c - j, k], {j, 1, o}]]];
    T[n_, k_] := b[n, 0, 0, k] - If[k == 0, 0, b[n, 0, 0, k - 1]];
    Table[Table[T[n, k], {n, k, k(k+1)/2}], {k, 0, 8}] // Flatten (* Jean-François Alcover, Mar 14 2021, after Alois P. Heinz *)
Showing 1-5 of 5 results.