factorial() — Factorial

Counts the different ways you can line x things up in order.

factorial(x)

Key idea

Definition

how many distinct items
x times (x-1) times ... times 1

Where you'd use it

Frequently asked questions

What is a factorial used for?
Counting arrangements (n!). It underlies permutations and combinations.
Why did I get Inf?
Above about 170, n! overflows R’s number range.