In number theory, the Kempner function S(n) is defined for a given positive integer n to be the smallest number s such that n divides the factorial s!. For example, the number 8 does not divide 1!, 2!, 3!, but does divide 4!, so S(8) = 4.
This function has the property that it grows linearly on the prime numbers but only grows sublogarithmically at the factorial numbers.
This function was first considered by François Édouard Anatole Lucas in 1883, followed by Joseph Jean Baptiste Neuberg in 1887. In 1918, A. J. Kempner gave the first correct algorithm for computing S(n). Florentin Smarandache rediscovered it in 1980 following which some other authors have called it the Smarandache function.
Since n divides n!, S(n) is always at most n. A number n greater than 4 is a prime number if and only if S(n) = n. That is, the numbers n for which S(n) is as large as possible relative to n are the primes. In the other direction, the numbers for which S(n) is as small as possible are the factorials: S(k!) = k, for all k ≥ 1.
S(n) is the smallest possible degree of a monic polynomial with integer coefficients, whose values over the integers are all divisible by n. For instance, the fact that S(6) = 3 means that there is a cubic polynomial whose values are all zero modulo 6, for instance the polynomial
but that all quadratic or linear polynomials (with leading coefficient one) are nonzero modulo 6 at some integers.
In one of the advanced problems in the American Mathematical Monthly, set in 1991 and solved in 1994, Paul Erdős pointed out that the function S(n) coincides with the largest prime factor of n for "almost all" n (in the sense that the asymptotic density of the set of exceptions is zero).