The Legendre’s formula calculator gives the exponent of a prime p in n! and in a binomial coefficient C(n, k), the number of carries in base p by Kummer’s theorem, the digit sum of n in base p and the trailing zeros of n! in base 10.
How the calculation works
- Enter n and the prime p.
- Enter k for the binomial coefficient C(n, k), with k at most n.
- Read the exponents, the carries and the trailing zeros.
Example
For n = 100 and the prime p = 5, the exponent of p in n! is 24. In k! with k = 40 it is 9, in (n − k)! it is 14, so in C(n, k) it is 1. The digit sum of n in base p is 4. The factorial of n ends with 24 zeros in base 10.
Why it matters
The calculator helps students of number theory, competition mathematicians and programmers who work with factorials and binomial coefficients, and who need the power of a prime in them, the divisibility of a binomial coefficient or the trailing zeros of a factorial.
Good to know
The formula requires p to be prime: the calculator does not check this, and a composite value gives a number that has no standard meaning. For the trailing zeros it uses the exponents of 2 and 5. For k larger than n, the binomial coefficient is not defined and the result has no meaning. The exponent of p in C(n, k) is also the number of carries when adding k and n − k in base p, which gives a quick way to see if a binomial coefficient is divisible by p.
Related tools
The factorial calculator gives the factorial and trailing zeros, the binomial calculator gives coefficients, the combinations calculator counts subsets and the prime number theorem calculator estimates how many primes there are.