Coin toss streak probability calculator
This coin toss streak probability calculator finds the chance that at least one run of consecutive heads appears within a chosen number of fair tosses.
Run — free
Enter the total toss count and the required streak length, and it evaluates every possible way the sequence can evolve without relying on simulation. The result includes both the event probability and its complement, making it useful for games, probability lessons, experiment planning, and checks of intuition about repeated independent trials.
What the calculator measures
The event measured here is at least one uninterrupted run of the requested length anywhere among the tosses. A run may begin on the first toss, finish on the last toss, or sit between tails. Longer runs also count: a sequence containing four consecutive heads satisfies a request for a three-head streak because it contains overlapping groups of three consecutive heads. The calculator does not ask for exactly that many total heads, and it does not require the streak to occur only once. Those are different probability questions. Every toss is assumed to be independent and fair, so heads and tails each have probability one half. For example, ten tosses with a target streak of three asks whether HHH appears at least once in any position across the ten outcomes. It does not matter how many additional heads occur elsewhere. If the requested streak exceeds the total toss count, the event cannot fit inside the experiment; this capability treats that mismatch as invalid input so configuration mistakes are visible rather than silently returned as an unhelpful result.
How the probability is calculated
Simply adding the probabilities for a streak starting at each possible position gives the wrong answer because candidate runs overlap. In HHHH, for example, a three-head run starts in two positions, but the outcome must be counted only once. This calculator avoids that double counting with dynamic programming. After every toss, it tracks the probability that the target has not appeared and that the current sequence ends with zero, one, two, or more consecutive heads, stopping one state short of the target length. A tail moves all surviving paths back to a trailing run of zero. A head advances each path to the next run length; any path that reaches the target is removed from the no-streak states. After all tosses, the surviving state probabilities are summed to obtain the chance of never seeing the requested run. Subtracting that value from one gives the probability of at least one streak. This method evaluates the event directly, is deterministic, and avoids the sampling error that comes with a Monte Carlo simulation.
How to interpret and use the result
The response reports probability as a number from zero to one, percent as the same result multiplied by one hundred, and probability_no_streak as the complementary event. A value of 0.5078125 means the requested run occurs in about 50.78125 percent of experiments conducted under the stated assumptions; it does not predict what a particular short sequence must do. Repeating an experiment many times should make its observed frequency approach the calculated probability, but random variation remains normal. Use the complement when planning around avoidance, such as estimating how often a game finishes without a long run. Compare several streak lengths to see how quickly rare patterns become plausible as the number of opportunities grows. Remember that the model is specifically for a fair, independent coin. A weighted coin, dependence between tosses, stopping rules, or a request for either heads or tails would require a different calculation. Inputs are bounded to one thousand tosses so the same pure algorithm remains responsive in the browser and through the API. For automated calls, each calculation costs $0.002; the page can also run it locally.
What you can do with it
Check a probability lesson
Compare intuition with the exact chance of observing consecutive heads over a fixed classroom experiment.
Design a tabletop rule
Estimate how frequently a bonus triggered by several heads in a row will occur during play.
Plan repeated trials
Choose a toss count that makes a target run common enough to demonstrate without using simulation.
FAQ
What does at least one streak mean?
It means the requested run appears anywhere one or more times. Any longer run also contains the requested streak and therefore counts.
Does this calculate exactly that many heads?
No. It calculates consecutive heads, regardless of how many heads appear outside the run. Use a binomial probability calculator for an exact total.
Why can I not set a streak longer than the toss count?
That run cannot fit within the experiment. The capability returns an invalid-input error to expose the inconsistent request.
Is the answer based on simulation?
No. A deterministic dynamic program accounts for overlapping possible runs and returns the mathematical probability without random sampling.
Does it support a biased coin, and what does the API cost?
No. Heads and tails are each assumed to have probability one half, and all tosses are independent. Each API request costs $0.002; you can also use the browser calculator on this page.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/coin-streak \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"tosses":10,"streak":3}'const res = await fetch("https://api.kit.forhosting.com/stat/coin-streak", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"tosses": 10,
"streak": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/coin-streak",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"tosses": 10,
"streak": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/coin-streak", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"tosses":10,"streak":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"tosses":10,"streak":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/coin-streak", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"tosses": 10,
"streak": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.coin_streak",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_tosses | 1000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |