Factorial
The factorial of a nonnegative integer n, written n!, is the product of all positive integers from 1 through n, with 0! equal to 1.
Statistics Every Programmer Needs
A factorial is the product of all positive integers from a given natural number down to one.
- How it is used
- Uses factorials to count ordered selections when replacement is not allowed.
- How deep it goes
- Defines factorials, works through numerical examples, derives a permutation formula, and implements it in Python.
- Examples
- Uses 5!, 3!, five runners competing for three positions, and Python results for 60 permutations.
- What you can do after
- Apply factorials via Python's math.factorial to calculate permutation counts without replacement.
Read how Statistics Every Programmer Needs explains factorial →
Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
A factorial is the product of all positive integers from one through a given nonnegative integer.
- How it is used
- Uses factorial to quantify the search space of brute-force traveling-salesman permutations.
- How deep it goes
- Defines factorial through permutation growth and stops short of deriving its formula or analyzing factorial algorithms.
- Examples
- Uses five, six, and seven cities to show how factorially many traveling-salesman paths expand.
- What you can do after
- Evaluate whether exhaustive permutation search is practical and recognize when near-optimal methods are preferable.
Related concepts
- sine functionused by · The sine function is a periodic trigonometric function that maps a real number or angle to a value between −1 and 1.
- recursionimplemented by · Recursion is a computational technique in which a definition or procedure refers to or invokes the same definition or procedure, directly or indirectly.
- permutationmeasures · A permutation is a bijective rearrangement of the elements of a finite set, equivalently an ordering in which each element appears exactly once.
- conditional logicuses · Conditional logic is a programming technique that selects execution paths, actions, or result values according to evaluated conditions.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

