Member-only story
Use Python to perform factorials, combinations and permutations of numbers and words
A few years ago I took a course on Alison that covers factorials, combinations, and permutations. I rushed through the course and as a result did not perform as well as I would have liked to have done. I recently decided to revisit that course to see if I can improve my knowledge of the subject matter, and decided to convert the course material to Python since that is the programming language that I have the most knowledge in.
Three of the concepts that I will cover in this blog post are:-
- Factorials
- Combinations
- Permutations
A factorial, denoted by an exclamation mark (!), is the product of all positive integers from 1 up to a given number.
For example, 5 factorial (written as 5!) means multiplying all the integers from 1 to 5: 5! = 5 * 4 * 3 * 2 * 1 = 120
The concept of a factorial is widely used in mathematics, especially in permutations, combinations, and probability calculations. Factorials help determine how many ways items can be arranged or selected.
One special case: 0 factorial (0!) is defined as 1 by convention. This is useful in mathematical formulas, particularly involving combinatorics.