Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 7

Understanding Factorials

Recommended resources

In our last lesson, we explored summation (Σ) and product (Π) notation, powerful tools for expressing long sequences of additions and multiplications. As we saw, this notation is crucial for defining complex mathematical and algorithmic ideas concisely. Today, we'll dive into a specific and fundamental application of product notation: the factorial.

This lesson concludes our first module on Mathematical Foundations. Our goal is to define and apply the concept of factorials. The factorial is not just a mathematical curiosity; it is the bedrock of an entire field called combinatorics, which is the study of counting. This concept is essential for understanding probability, analyzing algorithms, and modeling various problems in computer science and AI.

1. What is a Factorial?

In the previous lesson, we briefly introduced the factorial of a number , denoted as , as the product of all positive integers up to . Using the product notation we just learned, we can write this formally as:

For example, (read as "four factorial") is .

Let's start by formalizing this definition and seeing a few more examples.

Factorial in Maths - GeeksforGeeks

This article from GeeksforGeeks provides a clear definition, the standard formula, and several worked-out examples.

Please read the introductory paragraphs to get the formal definition. Look for the text from the definition and the list of initial examples. Then, glance at the "Factorial Examples" section to see how quickly factorial values grow, especially for 10! and 100!.

As you can see, factorial values grow extremely rapidly. This rapid growth is a key feature and has important implications in computer science when designing algorithms that involve counting arrangements.


2. The Core Meaning: Counting Arrangements

While the definition of a factorial is a simple product, its real power comes from what it represents: the number of ways to arrange a set of distinct items. This is also known as the number of permutations.

Imagine you have three club members: Bob, Duc, and Mai. You need to assign them to three distinct officer roles: President, Secretary, and Treasurer. How many different ways can you make these assignments?

You have 3 choices for President. Once the President is chosen, you have 2 remaining choices for Secretary. Finally, you have only 1 person left for the Treasurer role. The total number of unique arrangements is therefore , which is exactly .

The image below illustrates all 6 possible arrangements.

This diagram shows the 6 unique ways to assign the roles of President, Secretary, and Treasurer to three individuals (Bob, Duc, Mai), visually representing the calculation of 3!.

This intuitive connection to arrangements is the most important takeaway about factorials. The following article reinforces this idea.

What is a Factorial? How to Calculate Factorials with Examples

This article from freeCodeCamp connects the mathematical definition of a factorial directly to its practical use in counting permutations.

Read the section "What is a Factorial Used For?" to solidify this connection. Then, review the example problem about arranging the letters in the word "camper".


3. The Curious Case of Zero Factorial (0!)

You may have noticed in the readings that is defined to be 1. This can seem counterintuitive at first. Why isn't it 0? This isn't an arbitrary rule; it's a necessary convention that makes the mathematics of factorials consistent. There are two excellent ways to understand this.

The video below explains both justifications clearly.

zero factorial, why 0! should be 1, 4 reasons

This video from the "blackpenredpen" channel provides two distinct and intuitive reasons why 0! must equal 1.

Watch the first explanation based on patterns, from the beginning. The presenter shows how you can work backward from 4!, dividing by 4, then 3, then 2, which logically leads to dividing 1! by 1 to find 0!. Next, watch the second explanation based on arrangements, from this timestamp. This connects to our discussion above. It asks: "How many ways can you arrange zero items?" The answer is that there is exactly one way to do this: the empty arrangement.

Both arguments lead to the same conclusion: for the mathematical and logical framework of combinatorics to hold together, we must define . We also saw this principle in our last lesson with empty products, which are defined as 1 (the multiplicative identity).


4. Working with Factorial Expressions

In practice, you will rarely calculate large factorials directly. Instead, you'll often need to simplify expressions that contain them. The key to this is the recursive property of factorials:

For example, . This allows us to expand a larger factorial until it matches a smaller one, enabling cancellation. This is especially useful when simplifying fractions.

This next video is excellent for learning these manipulation techniques, both with numbers and with algebraic variables.

Factorials Explained!

This video from "The Organic Chemistry Tutor" demonstrates how to simplify various expressions involving factorials.

First, watch the examples on simplifying numerical fractions, such as 9!/7!, starting from this point and another example at this point. Notice how the larger factorial is expanded. Next, and most importantly, watch the section on simplifying algebraic expressions with variables like n, from this timestamp. Understanding how to simplify (n+1)! / n! is a crucial skill that builds directly on the numerical examples.

Let's try one ourselves. How would we simplify ?

  1. Identify the largest factorial in the denominator, which is .
  2. Expand the numerator until you reach that factorial: .
  3. Rewrite the expression: .
  4. Cancel the common term : .
  5. Expand the remaining factorial in the denominator: .
  6. The expression becomes .
  7. Cancel the 6s to get the final answer: .

This skill of simplification is fundamental for probability theory and calculus, where you'll encounter formulas built from factorials.


Conclusion

This lesson marks the end of our introductory module on mathematical foundations. We've journeyed from basic algebra and functions to the powerful notations of Σ, Π, and now, the factorial. These concepts form a crucial part of the language of computer science and AI.

Here are the key takeaways on factorials:

  • The factorial is the product of all positive integers from 1 to .
  • Its primary application is in combinatorics: counts the number of unique ways to arrange (permute) distinct objects.
  • By convention and for logical consistency, .
  • The recursive relationship is the key to simplifying complex factorial expressions.

You have successfully built a foundational toolkit of mathematical concepts. Now, you are ready to apply this logical thinking in a new domain. In our next lesson, we will begin Module 2: Introduction to Python Programming. We will start from the very beginning, setting up your computer so you can write and run your first lines of code. This is where your journey to building intelligent systems truly begins