The factorial is defined for positive integers as Alternatively, a recursive definition for the factorial is: .
By convention, is given the value .
The gamma function is a generalization of the factorial to values other than nonnegative integers.
Since is the product of all positive integers not exceeding , it is clear that it is divisible by all primes and not divisible by any prime . But what is the power of a prime in the prime factorization of ? We can find it as the sum of powers of in all the factors but rather than counting the power of in each factor, we shall count the number of factors divisible by a given power of . Among the numbers exactly are divisible by (here is the floor function). Now we will use the Lebesgue counting principle that says that the sum of several non-negative integers (the powers of in numbers in our case) can be found as . This immediately gives the formula
for the power of in the prime factorization of . The series is formally infinite, but the terms become pretty fast. For example, the power of in is just ( is already greater than ).