// COMBINATORICS · INTERMEDIATE
Permutations & CombinationsFactorials, nPr, nCr, Pascal's triangle, and the binomial theorem — the counting toolkit behind algorithm analysis.
Prerequisites: Basic arithmetic · Algebra · Exponents
// VISUALIZER
Build Pascal's triangle step by step
Each entry is the sum of the two above it. Entry (n, r) equals C(n, r). Each row sums to 2^n. Watch the triangle grow.
Each entry is the sum of the two above it. Entry (n, r) = C(n, r). Row n sums to 2^n.
Row sum
2^5 = 32
Total entries
21
// CALCULATOR
nPr vs nCr — see the difference
Pick n and r. Compare permutations (order matters) with combinations (order doesn't). Each combination produces r! permutations.
Permutation (order matters)
8P3 = 8! / (8-3)!
336
Combination (order doesn't matter)
8C3 = 8! / (3! × (8-3)!)
56
8P3 = 336 arrangements (ordered). 8C3 = 56 selections (unordered). The ratio is r! = 6 — each combination produces 6 permutations.
// MINI GAME
Counting Quest
Solve counting problems against the clock! Factorials, permutations, combinations, circular arrangements, and the counting principle. Use hints wisely — they cost XP.
Loading quest...
// FLOWCHART
Algorithm flow
Press PLAY to trace the algorithm through the flowchart.
// PSEUDOCODE
Trace the code
Press PLAY to step through the algorithm line by line.
// TUTORIAL QUIZZES
Test your mastery
From the fundamental counting principle to Pascal's triangle, derangements, and competitive programming shortcuts.
// PRACTICE & ASSESS
Test your understanding
Now that you've learned the concept, put it into practice. Solve coding problems and take quizzes to reinforce what you've learned.
// REFERENCES
Sources & further reading
- [1]Pascal's TriangleBlaise Pascal (1653) — Traité du triangle arithmétique
- [2]Ars ConjectandiJacob Bernoulli — combinatorics and probability
- [3]Introduction to Algorithms (CLRS)T. H. Cormen et al. — combinatorial analysis and counting
- [4]Concrete MathematicsRonald L. Graham, Donald E. Knuth, Oren Patashnik — combinatorics for CS
// READY?
Distribute identical objects into bins
Next up: Stars and Bars — a classic combinatorics technique for counting distributions.