Alternating Factorial

Author

Eric W. Weisstein
September 19, 2017

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Combinatorics/AlternatingFactorial.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/AlternatingFactorial.html.

©2017 Wolfram Research, Inc. except for portions noted otherwise

Sequence

A005165

AlternatingFactorial[Range[0,10]]

Typesetting

AlternatingFactorial[n]//TraditionalForm

Sums

(∑_(k=1)^n)k! (((-1))^(n-k))==(AlternatingFactorial[n])

Sum[(-1)^(n-k)k!,{k,1,n}]

(∑_(k=1)^n)k! (((-1))^(n-k))==(AlternatingFactorial[n])

Sum[(((-1))^(n-k))k!,{k,n}]

Closed Forms

e (ExpIntegralE[n+2, 1]) (Gamma[n+2])+(e (ExpIntegralEi[-1])+1) (((-1))^(n+1))

expr1=(((-1))^(1+n)) (1+E ExpIntegralEi[-1])+E ExpIntegralE[2+n,1] Gamma[2+n];
expr2=AlternatingFactorial[n];

Table[{expr1,expr2},{n,10}]//FullSimplify

FullSimplify[expr1]

FullSimplify[expr1,n∈Integers]

bug(337545): FullSimplify[(-1)^(1 + n) (1 + E ExpIntegralEi[-1]) + E ExpIntegralE[2 + n, 1] Gamma[2 + n], Element[n, Integers]] could return AlternatingFactorial (different simplifies to 0)

FullSimplify[expr1-expr2]

FullSimplify[expr1-expr2,n∈Integers]

Recurrence

RSolve[{a[n]==n!-a[n-1],a[1]==1},a[n],n]

Table[(((-1))^n) (-1+2 E ExpIntegralE[3,1]+(((-1))^n) E ExpIntegralE[2+n,1] Gamma[2+n]),{n,10}]//FullSimplify

bug(265427): RSolve[{a[n] == n! - a[n - 1], a[1] == 1}, a[n], n] could return AlternatingFactorial[n] directly

RecurrenceTable[{a[n]==n!-a[n-1],a[0]==0},a,{n,0,20}]

Primes

A001272

Position[Table[PrimeQ[AlternatingFactorial[n]],{n,100}],True]//Flatten//Timing

Position[AlternatingFactorial[Range[200]],_?PrimeQ]//Flatten

primes={3,4,5,6,7,8,10,15,19,41,59,61,105,160,661,2653,3069,3943,4053,4998,8275,9158,11164,43592,59961};

IntegerLength[AlternatingFactorial[primes]]

TextGrid[MapIndexed[{#2[[1]],#,IntegerLength[AlternatingFactorial[#]]}&,primes],Dividers->All,Alignment->Decimal]

$Version

DateString[]

Do[Print[{n,PrimeQ[AlternatingFactorial[n]]//Timing}],{n,primes}]

n Divides a(n)

DividesAlternatingSumQ[n_]:=IntegerQ[FullSimplify[-E (ExpIntegralEi[-1]+(((-1))^n) ExpIntegralE[1+n,1] Gamma[1+n])]/n]

Select[Range[100],DividesAlternatingSumQ]//Timing