Factorials & trailing zeroes
easy 14 minn!
Where it shows up
The same pattern appears across everyday software.
Brute-force search spaces
Trying every route through n cities (the travelling salesman problem) checks on the order of n! orders. Engineers use the factorial to see at a glance that 10 stops is fine and 20 stops is hopeless without dynamic programming or heuristics.
Password and key strength
Security analysis counts arrangements: an 8-letter password with no repeated letters has 26!/18!, about 63 billion, possibilities. These counts set how long a brute-force attack would take.
Probability and statistics
Binomial coefficients built from factorials give the odds of k successes in n trials, lottery odds, and the binomial and Poisson distributions used in A/B testing and reliability analysis.
Competitive programming
Counting problems ask for answers modulo 10^9 + 7. The standard toolkit precomputes factorials and inverse factorials once, so every nCr afterwards takes O(1).
Sorting theory
Stirling's approximation gives log2(n!) = Theta(n log n), the lower bound for any comparison sort. It is why library sorts aim for O(n log n) and why beating it needs non-comparison methods like counting or radix sort.