Formulas
In addition to these, also see the Mathematical Series discussed in Analysis of Algorithms.
- Permutations -
- Combinations (Repetition not allowed) -
- Combinations (Repetition allowed), bars and stars example in Question 2 -
- Pascal’s rule -
Q1) Find a formula for counting the number of diagonals in an n-gon
Sol - The vertices can be connected using a line in ways. Out of these connections, connections would be edges connecting adjacent vertices. Thus the number of diagonals is .

Q2) A shopkeeper has 3 ice-cream flavors. In how many ways can he sell these flavors to 10 kids
Sol - Consider 12 slots and 2 sticks. These 2 sticks can be used to divide the 12 slots into 3 sections like this -

So now the problem has shifted to picking 2 slots from 12 total slots to insert the sticks in. Thus the answer is . A more general solution to this would be where is the number of children and is the number of flavors.
Q3) In how many ways can we write 100 as a sum of 4 non-negative integers.
Sol - This can be modelled as a similar problem with 103 slots and 3 sticks. Thus the solution is
Binomial Theorem
In the expansion of , each term is of the form where and . For any term , must have been contributed by number of terms while the rest number of terms contributed towards . We can choose of the factors from which is selected in ways. Thus the coefficient of any term is .
Interesting Applications
- Euler’s constant -
- Derivative of
- We know . What if ?
- Using a similar logic we can find -
- Extended binomial coefficient - For any real number , the binomial coefficient is defined by . Now let and substitute . Then,
- Using this we can find -
term of the Binomial Expansion
The term of the Binomial Expansion is always -
Multinomial Theorem
What would the coefficients of each term look like in the expansion of ?
We can consider where . Upon expansion by applying the binomial theorem, any term (for simpler calculations without loss of generalization) would be of the form -
where . The coefficient of some term of this expansion would be -
We can continue doing this expansion until becomes a binomial. By that point, the coefficient of the of the original multinomial would be -
Pascal’s Triangle

Each row of the Pascal’s Triangle contains the Binomial Coefficients of the expansion .
Fun Facts
- The second diagonal is the sequence of Natural Numbers.
- Each row’s sum is .
- Each row also denotes .
Catalan’s Numbers
In how many ways can one reach from in the below grid?

Pigeon Hole Principle
The principle states that if we have pigeons and pigeon holes such that . Then there would at least be one pigeon hole such that at least 2 pigeons reside in it.
Usually used in finding the worst case of the number of item pickings such that it satisfied some constraint.
Q4) What is the minimum number of ways people can be seated in a hall such that it always ensures that at least two people share the same first name and last name initials.
Sol - There are a total of 26 letter in the English Alphabets. So a person’s initial can be - A.A., A.B., A.C., , Z.Z. Only after all initials have been covered can we say that seating one more person will ensure that at least two people share the same initials. Thus the number of pigeon holes we have is and the number of “pigeons” or minimum number of people needed is .
Generating Function
The idea of a generating function is if you have some question with the answer associated with some positive integer, you can model the problem as a polynomial such that the coefficients of certain terms would correspond to this answer.
Say we want the number of subsets of such that the sum of the elements in each subset is equal to 5. We can model this as a polynomial problem of such that the coefficient corresponding to in the product would be this count. Here is your generating function.
No idea how someone thought of this (even 3Blue1Brown doesn’t) but it can be seen why the above example would work. A generating function is of the form -
Recurrence Relation
Back Substitution is discussed in Analysis of Algorithms, so only method of characteristic roots will be discussed here.