Kamis, 05 Maret 2009

FACTORIAL

Factorial

The factorial n! is defined for a positive integer n as

 n!=n(n-1)...2·1.
(1)

So, for example, 4!=4·3·2·1=24. An older notation for the factorial is FactorialOld (Mellin 1909; Lewin 1958, p. 19; Dudeney 1970; Gardner 1978; Conway and Guy 1996).

The special case 0! is defined to have value 0!=1, consistent with the combinatorial interpretation of there being exactly one way to arrange zero objects (i.e., there is a single permutation of zero elements, namely the empty set emptyset).

The factorial is implemented in Mathematica as Factorial[n] or n!.

The triangular number T_n=n+(n-1)+...+2+1 can be regarded as the additive analog of the factorial n!=n·(n-1)...2·1. Another relationship between factorials and triangular numbers is given by the identity

 (2n)!=2^nproduct_(k=1)^nT_(2k-1)
(2)

(K. MacMillan, pers. comm., Jan. 21, 2008).

The factorial n! gives the number of ways in which n objects can be permuted. For example, 3!=6, since the six possible permutations of {1,2,3} are {1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1}. The first few factorials for n=0, 1, 2, ... are 1, 1, 2, 6, 24, 120, ... (Sloane's A000142).

The numbers of digits in (10^n)! for n=0, 1, ... are 1, 7, 158, 2568, 35660, 456574, 5565709, 65657060, ... (Sloane's A061010).

Generalizations of the factorial such as the double factorial n!! and multifactorial n!...!_()_(k) can be defined. Note, however, that these are not equal to nested factorials (n!)!, ((n!)!)!, etc.

The first few values of (n!)! for n=1, 2, ... are 1, 2, 720, 620448401733239439360000, ... (Eureka 1974; Sloane's A000197). The numbers of digits in (n!)! are 1, 1, 3, 24, 199, 1747, ... (Sloane's A063979).

As n grows large, factorials begin acquiring tails of trailing zeros. To calculate the number Z of trailing zeros for n!, use

 Z=sum_(k=1)^(k_(max))|_n/(5^k)_|,
(3)

where

 k_(max)=|_log_5n_|
(4)

and |_x_| is the floor function (Gardner 1978, p. 63; Ogilvy and Anderson 1988, pp. 112-114). For n=1, 2, ..., the number of trailing zeros are 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, ... (Sloane's A027868). This is a special application of the general result first discovered by Legendre in 1808 that the largest power of a prime p dividing n! is

 epsilon_p(n)=sum_(k=1)^(|_log_pn_|)|_n/(p^k)_|
(5)

(Landau 1974, pp. 75-76; Honsberger 1976; Hardy and Wright 1979, pp. 342; Ribenboim 1989; Ingham 1990, p. 20; Graham et al. 1994; Vardi 1991; Hardy 1999, pp. 18 and 21; Havil 2003, p. 165; Boros and Moll 2004, p. 5). This can be implemented in Mathematica as

  HighestPower[p_?PrimeQ, n_] :=

Sum[Floor[n/p^k], {k, Floor[Log[p,n]]}]

Stated another way, the exact power of a prime p which divides n! is

 (n-s_p(n))/(p-1),
(6)

where s_p(n) is the digit sum of n in base b (Boros and Moll 2004, p. 6). This can be implemented in Mathematica as

  HighestPower2[p_Integer?PrimeQ, n_] :=

(n - Total[IntegerDigits[n, p]])/(p - 1)

Therefore, as shown by Legendre,

 n!=product_(p<=n)p^(epsilon_p(n))
(7)

(Havil 2003, p. 165).

Let a(n) be the last nonzero digit in n!, then the first few values are 2, 6, 4, 2, 2, 4, 2, 8, 8, 8, 6, 8, ... (Sloane's A008904). This sequence was studied by Kakutani (1967), who showed that this sequence is "5-automatic," meaning roughly that there exists a finite automaton which, when given the digits of n in base-5, will wind up in a state for which an output mapping specifies a(n). The exact distribution of digits follows from this result.

Factorial
FactorialReImAbs



Min
Max


Re

Register for Unlimited Interactive Examples >>


Im
Powered by webMathematica

By noting that

 n!=Gamma(n+1),
(8)

where Gamma(n) is the gamma function for integers n, the definition can be generalized to complex values

 z!=Gamma(z+1)=int_0^inftye^(-t)t^zdt.
(9)

This defines z! for all complex values of z, except when n is a negative integer, in which case n! is equal to complex infinity.

While Gauss (G1) introduced the notation

 Pi(s)=Gamma(s+1),
(10)

this notation was subsequently abandoned after Legendre introduced the gamma-notation (Edwards 2001, p. 8).

Using the identities for gamma functions, the values of (1/2n)! (half integral values) can be written explicitly

(-1/2)!=sqrt(pi)
(11)
(1/2)!=1/2sqrt(pi)
(12)
(n-1/2)!=(sqrt(pi))/(2^n)(2n-1)!!
(13)
(n+1/2)!=(sqrt(pi))/(2^(n+1))(2n+1)!!,
(14)

where n!! is a double factorial.

For integers s and n with s<n,

 ((s-n)!)/((2s-2n)!)=((-1)^(n-s)(2n-2s)!)/((n-s)!).
(15)

The logarithm of z! is frequently encountered

ln(z!)=1/2ln[(piz)/(sin(piz))]-gammaz-sum_(n=1)^(infty)(zeta(2n+1))/(2n+1)z^(2n+1)
(16)
=1/2ln[(piz)/(sin(piz))]-1/2ln((1+z)/(1-z))+(1-gamma)z-sum_(n=1)^(infty)[zeta(2n+1)-1](z^(2n+1))/(2n+1)
(17)
=sum_(n=1)^(infty)(z^n)/(n!)psi_(n-1)(1)
(18)
=-gammaz+sum_(n=2)^(infty)(-1)^n(z^n)/nzeta(n)
(19)
=-ln(1+z)+z(1-gamma)+sum_(n=2)^(infty)(-1)^n[zeta(n)-1](z^n)/n,
(20)

where gamma is the Euler-Mascheroni constant, zeta(z) is the Riemann zeta function, and psi_n(z) is the polygamma function.

It is also given by the limit

ln(z!)=infty)(zn!)/((z)_(n+1))n^z]" border="0" height="39" width="98">
(21)
=infty)(n!)/((z+1)_n)n^z]" border="0" height="39" width="109">
(22)
=infty)lim_(n->infty)(n!)/((z+1)(z+2)...(z+n))n^z]" border="0" height="37" width="221">
(23)
=infty)[ln(n!)+zlnn-ln(z+1)-ln(z+2)-...-ln(z+n)]," border="0" height="24" width="341">
(24)

where (z)_n is the Pochhammer symbol.

where gamma is the Euler-Mascheroni constant, zeta(z) is the Riemann zeta function, and psi_n(z) is the polygamma function. The factorial can be expanded in a series

 z!=sqrt(2pi)z^(z+1/2)e^(-z)(1+1/(12)z^(-1)+1/(288)z^(-2)-(139)/(51840)z^(-3)+...)
(25)

(Sloane's A001163 and A001164). Stirling's series gives the series expansion for ln(z!),

ln(z!)=1/2ln(2pi)+(z+1/2)lnz-z+(B_2)/(2z)+...+(B_(2n))/(2n(2n-1)z^(2n-1))+...
(26)
=1/2ln(2pi)+(z+1/2)lnz-z+1/(12)z^(-1)-1/(360)z^(-3)+1/(1260)z^(-5)-...
(27)

(Sloane's A046968 and A046969), where B_n is a Bernoulli number.

In general, the power-product sequences (Mudge 1997) are given by S_k^+/-(n)=(n!)^k+/-1. The first few terms of S_2^+(n) are 2, 5, 37, 577, 14401, 518401, ... (Sloane's A020549), and S_2^+(n) is prime for n=1, 2, 3, 4, 5, 9, 10, 11, 13, 24, 65, 76, ... (Sloane's A046029). The first few terms of S_2^-(n) are 0, 3, 35, 575, 14399, 518399, ... (Sloane's A046032), but S_2^-(n) is prime for only n=2 since S_2^-(n)=(n!)^2-1=(n!+1)(n!-1) for 2" border="0" height="14" width="29">. The first few terms of S_3^-(n) are 0, 7, 215, 13823, 1727999, ... (Sloane's A046033), and the first few terms of S_3^+(n) are 2, 9, 217, 13825, 1728001, ... (Sloane's A019514).

The first few numbers n such that the sum of the factorials of their digits is equal to the prime counting function pi(n) are 6500, 6501, 6510, 6511, 6521, 12066, 50372, ... (Sloane's A049529). This sequence is finite, with the largest term being a_(23)=11071599.

Numbers n such that

 (n-1)!+1=0 (mod n^2),
(28)

are called Wilson primes.

Brown numbers are pairs (m,n) of integers satisfying the condition of Brocard's problem, i.e., such that

 n!+1=m^2.
(29)

Only three such pairs are known: (5, 4), (11, 5), (71, 7). Erdős conjectured that these are the only three such pairs (Guy 1994, p. 193).