Discrete Mathematics Formulas: A Cheat Sheet with Examples

Last updated · Part of the Discretiq guides

This page collects the formulas students need most in a first discrete mathematics course, grouped by topic, each with a small numeric example so you can see it work. Memorising a formula helps less than knowing when it applies, so each group notes the condition to check.

Logic

LawFormula
De Morgan¬(P ∧ Q) ≡ ¬P ∨ ¬Q; ¬(P ∨ Q) ≡ ¬P ∧ ¬Q
ImplicationP → Q ≡ ¬P ∨ Q ≡ ¬Q → ¬P (contrapositive)
BiconditionalP ↔ Q ≡ (P → Q) ∧ (Q → P)
Rows in a truth table2ⁿ for n variables

Sets

IdeaFormulaExample
Inclusion–exclusion|A ∪ B| = |A| + |B| − |A ∩ B|30 + 20 − 8 = 42
Subsets of an n-set2ⁿ5 elements: 32 subsets
Cartesian product size|A × B| = |A| · |B|3 · 4 = 12
De Morgan for sets(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ

Counting

IdeaFormulaExample
PermutationsP(n, r) = n!/(n − r)!P(10, 3) = 720
CombinationsC(n, r) = n!/(r!(n − r)!)C(10, 3) = 120
With repetition, order mattersnʳ3² = 9
With repetition, order ignoredC(n + r − 1, r)C(4, 2) = 6
SymmetryC(n, r) = C(n, n − r)
Row sum of Pascal's triangleΣ C(n, k) = 2ⁿn = 5: 32

Sums and sequences

IdeaFormulaExample
Sum of 1 to nn(n + 1)/2n = 100: 5,050
Geometric sumΣ rⁱ (i = 0..n) = (rⁿ⁺¹ − 1)/(r − 1)r = 2, n = 9: 1,023
Sum of first n odd numbersn²

Number theory

IdeaFormulaExample
GCD and LCMgcd(a, b) · lcm(a, b) = |ab|gcd(252, 105) = 21, lcm = 1,260
Euclidgcd(a, b) = gcd(b, a mod b)
Totient of a prime powerφ(pᵏ) = pᵏ − pᵏ⁻¹φ(49) = 42
Fermat's little theoremaᵖ⁻¹ ≡ 1 (mod p), p prime, p ∤ a3⁶ ≡ 1 (mod 7)

Graphs and trees

IdeaFormulaExample
Handshaking lemmaΣ deg(v) = 2|E|
Edges in complete graph Kₙn(n − 1)/2K₆: 15
Edges in a tree|V| − 1
Euler's formula (connected planar graph)V − E + F = 2

Relations and functions

IdeaFormulaExample
Relations on an n-set2^(n²)n = 3: 2⁹ = 512
Functions from m to n elementsnᵐ4 → 3: 81
One-to-one functions from m to n elementsP(n, m)3 → 5: 60

Using the formulas safely

  • Check the conditions first: Fermat's theorem needs a prime modulus, Euler's formula needs a connected planar graph.
  • Substitute a tiny case to test your formula before trusting it with big numbers.
  • Use a calculator to check the final value, but write the working yourself.

Frequently asked questions

Which formulas matter most for exams?

Counting formulas, logical equivalences, the gcd and Euclid facts, the handshaking lemma and sum formulas appear most often in introductory courses.

Are these formulas the same in every textbook?

The mathematics is, but notation varies, for example nCr versus C(n, r).

Try it yourself

Work the examples above by hand first, then confirm your answers.

Follow the learning path through every topic in order

References and further reading

  • Rosen, K. H. Discrete Mathematics and Its Applications. McGraw-Hill (standard undergraduate text).
  • Graham, R., Knuth, D., Patashnik, O. Concrete Mathematics. Addison-Wesley.