How to Calculate the Chance of Exactly k Heads in n Coin Flips
The binomial coefficient C(n,k) is the number of distinct ordered sequences containing exactly k successes among n trial positions.
A worked example with numbers
Take eight fair flips and ask for exactly three heads. First choose the three positions: C(8,3) = 8! ÷ (3! × 5!) = 56. Each one fully specified eight-flip sequence has probability (1/2)^8 = 1/256. Multiplying 56 sequences by 1/256 gives 56/256 = 0.21875, or 21.875%. The order H-T-H-T-T-H-T-T counts, but so does every other placement of three H values.
How to set the rule before the result
For an unfair but stable coin with heads probability p, use C(n,k) × p^k × (1-p)^(n-k). Set n to the number of flips actually planned, k to the exact count, and do not replace “exactly” with “at least.” The multiple coin flip tool can display a concrete sample; it does not replace a formula for every possible sample. A probability calculator is useful only after its event and assumptions match the question.
Common mistakes that change the odds or the process
A common mistake is using only (1/2)^k. That gives the probability of heads in k named positions, not exactly k heads anywhere among n positions. Another is treating 3 heads in 8 flips as the same as 3 or more heads; the latter adds probabilities for 4, 5, 6, 7, and 8 heads. Do not round early: 56/256 is exact, while 0.22 is only a display approximation.
Where this method stops being appropriate
This formula needs n independent trials and a constant probability p for each trial. It does not describe draws without replacement, a coin whose mechanism changes, or a game rule that stops as soon as a target count occurs. It also cannot decide whether a short observed sample proves a coin fair. Use it to calculate the chance under explicit assumptions, not to manufacture certainty from a result.
How the random source fits into the rule
NIST’s binomial-distribution reference states the binomial probability function for n independent experiments with success probability p. Its fair-coin special case sets p = 1/2. The implementation source for a browser’s strong random integers is MDN’s Crypto.getRandomValues reference; source quality and the combinatorial count are separate questions.
Read the formula’s three parts
C(n,k) counts placements, p^k gives the probability of the k head positions, and (1-p)^(n-k) gives the probability of the tail positions. For a fair coin p = 1/2, so every full sequence has the same probability 1/2^n. The coefficient is necessary because “exactly k” includes many sequences. In ten flips with four heads, C(10,4) = 210, not one, is the number of accepted placements.
Make a small table before using software
| Event in 4 fair flips | Favourable sequences | Probability |
|---|---|---|
| Exactly 0 heads | 1 | 1/16 = 6.25% |
| Exactly 2 heads | 6 | 6/16 = 37.5% |
| Exactly 4 heads | 1 | 1/16 = 6.25% |
The entries total 16 when all five possible head counts are included, matching 2^4 ordered sequences.
Exactly, at least, and at most are different requests
For at least three heads in four flips, add exactly three and exactly four: 4/16 + 1/16 = 5/16 = 31.25%. For at most one head, add exactly zero and exactly one. These additions work because the exact-count events cannot occur together in the same four-flip sample. Write the inequality before calculating so a familiar formula does not answer the wrong question.
Explain the answer with its assumptions
Say “exactly 3 heads in 8 independent fair flips has probability 21.875%” rather than “three heads is 21.875%.” The first statement names the count, trial number, and model. It also makes clear why a different sample size, a loaded coin, or a stopped-early game requires a different calculation.
Check the distribution totals one
For any fixed n, probabilities for exactly 0 through exactly n heads must sum to 1. With n = 3, the probabilities are 1/8, 3/8, 3/8, and 1/8. This is a useful arithmetic check: the coefficients 1, 3, 3, 1 add to 8, which is 2^3. If a table of mutually exclusive exact counts does not total 100%, a coefficient, denominator, or rounding step is wrong.
Use fractions while adding several exact cases, then convert the final answer to a percentage. That practice keeps a calculator display from hiding an error such as adding 0.333 and 0.333 before the full event is defined.
Use a reproducible notation
Write the calculation as C(8,3)(1/2)^3(1/2)^5 = 56/256. A reader can see both the number of placements and the probability of each placement. This notation also makes the generalisation to another coin probability p visible without changing the event description.
For a check, swap heads and tails: exactly three heads in eight fair flips has the same probability as exactly five heads, because every sequence has a mirrored sequence. Symmetry is a useful way to spot an incorrect coefficient near the two sides of the distribution.