A005165 Alternating factorials: n! - (n-1)! + (n-2)! - ... 1!.
0, 1, 1, 5, 19, 101, 619, 4421, 35899, 326981, 3301819, 36614981, 442386619, 5784634181, 81393657019, 1226280710981, 19696509177019, 335990918918981, 6066382786809019, 115578717622022981, 2317323290554617019, 48773618881154822981
Offset: 0
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).
Links
- T. D. Noe, Table of n, a(n) for n = 0..100
- Richard K. Guy, Letter to N. J. A. Sloane, Sep 25 1986.
- Richard K. Guy, Letter to N. J. A. Sloane, 1987
- Richard K. Guy, The strong law of small numbers. Amer. Math. Monthly 95 (1988), no. 8, 697-712.
- Richard K. Guy, The strong law of small numbers. Amer. Math. Monthly 95 (1988), no. 8, 697-712. [Annotated scanned copy]
- Hisanori Mishima, Factorizations of many number sequences: 103 and 130.
- Alexsandar Petojevic, The Function vM_m(s; a; z) and Some Well-Known Sequences, Journal of Integer Sequences, Vol. 5 (2002), Article 02.1.7.
- Eric Wegrzynowski, Séries de factorielles.
- Eric Weisstein's World of Mathematics, Alternating Factorial and Factorial.
- Miodrag Živković, The number of primes Sum_{i=1..n} (-1)^(n-i)*i! is finite, Math. Comp. 68 (1999), pp. 403-409.
- Index entries for sequences related to factorial numbers.
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
Comments