Flip a coin any number of times

Generate a bounded heads-and-tails sequence with side totals and its longest consecutive run.

freeworks offlinenothing uploaded
ToolCoin Flipper
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Unseeded flips draw 32-bit Web Crypto values and use rejection sampling before mapping the two equally sized outcomes to heads and tails. Seed text instead drives a repeatable Mulberry32 stream, and one scan of the finished sequence counts both sides and updates the longest run whenever a streak grows.

Formula
heads + tails = requested flips
  • The flip count is required and capped at 10,000 because every individual result is returned.
  • Leaving seed blank preserves unpredictability; entering one deliberately favours replayability.

Worked example

Ten flips
A seed makes the sequence repeatable
Input
											Count: 10
Seed: kickoff
										
Output
												Sequence: H,H,T,H,H,H,H,H,H,H
Heads: 9
Tails: 1
Longest run: 7
Longest run side: H
											

When to use this

Classroom probability exercises inspect counts and streaks, board games resolve a two-way tie, and deterministic software fixtures replay one exact binary sequence.

Edge cases

  • The same non-empty seed and count repeat exactly, so that mode must not be used for secret or adversarial stakes.
  • A one-flip sequence records a longest run of one even though no side transition occurs.
  • More than 10,000 requested outcomes are rejected before an unbounded comma-separated sequence is built.

References