The alternating factorial is defined as the sum of consecutive factorials with alternating signs for a nonnegative
integer ,
|
(1)
|
It can be given in closed form as
|
(2)
|
where
is the exponential integral,
is the En-function,
and
is the gamma function.
The alternating factorial is implemented in the Wolfram Language as AlternatingFactorial[n].
A simple recurrence equation for is given by
|
(3)
|
for ,
with
and
.
For ,
2, ..., the first few values are 1, 1, 5, 19, 101, 619, 4421, 35899, ... (OEIS A005165).
Alternating factorial primes are alternating factorials that are prime.