liveBook · Manning

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.

How 2 Manning books explain it

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.

Read how Classic Computer Science Problems in Swift: Essential techniques for practicing programmers explains factorial →

Related concepts

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.