If a choice is made in one of two ways, with a options for the first and b options for the second, then the number of ways to make the choice is a+b.
Product Rule
The number of ways to make a sequence of two separate choices, with a options for the first and b options for the second, is a⋅b.
Combinatorics
Permutations
The number of ways to order n objects is n!.
The number of ways to order k objects from a set of n objects is (n−k)!n!.
Combinations
The number of subsets of size k for a set of size n is k!(n−k)!n!=(kn).
How many bitstrings of length n have exactly k ones?
Stars and Bars
You have room for n fruits in your basket, and there are k different types of fruit. How many ways can you fill up your basket with n fruits?
You can partition your basket into k groups so that placing a fruit in a group indicates that you take a fruit of that type. This partitioning can be accomplished using k−1 bars as the boundaries. Then the number of configurations is the number of ways to place the n fruits and k−1 bars in a sequence, or (nn+k−1).
Example: a basket with capacity n=5 fruits and k=3 types of fruits: apples, oranges, and bananas.
apples oranges bananas
● ● | | ● ● ●
This is the same as the number of nonnegative integer solutions to napple+norange+nbanana=5.
Counting
Sum Rule
Product Rule
Combinatorics
Permutations
Combinations
Stars and Bars
apples oranges bananas
● ● | | ● ● ●
Summary
Inclusion-exclusion