Combinatorics
Glissez pour afficher le menu
Combinatorics is the branch of mathematics focused on counting the number of ways things can be arranged or selected. Two fundamental concepts in combinatorics are permutations and combinations. Understanding when to use each is crucial for solving probability problems.
Permutations
A permutation refers to an arrangement of items where the order matters. The number of ways to arrange n distinct objects in a sequence is given by the factorial of n, written as n!.
If you want to arrange r items out of n available, the formula for the number of permutations is:
P(n,r)=(n−r)!n!Step-by-step example:
Suppose you have 5 different books and want to know in how many ways you can arrange 3 of them on a shelf.
- Total items (n): 5
- Number to arrange (r): 3
- Calculation: P(5,3)=(5−3)!5!=2120=60
So, there are 60 possible arrangements.
Combinations
A combination is a selection of items where the order does not matter. The formula for the number of ways to choose r items from n is:
C(n,r)=r!(n−r)!n!Step-by-step example:
Suppose you need to select 3 team members from a group of 5 candidates.
- Total candidates (n): 5
- Number to select (r): 3
- Calculation: C(5,3)=3!×2!5!=6×2120=12120=10
So, there are 10 different ways to form the team.
12345678910111213import math # Calculate permutations: number of ways to arrange r items out of n, order matters def permutations(n, r): return math.factorial(n) // math.factorial(n - r) # Calculate combinations: number of ways to choose r items from n, order does not matter def combinations(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n - r)) # Example usage print("Permutations of 5 items taken 3 at a time:", permutations(5, 3)) print("Combinations of 5 items taken 3 at a time:", combinations(5, 3))
Merci pour vos commentaires !
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion