Short answer
The figure usually quoted is about ten million, and it is a rough estimate rather than a measurement. It comes from multiplying the number of distinguishable steps along a few perceptual dimensions, and the answer changes substantially depending on viewing conditions, the observer, and what counts as 'distinguishable'.
The common estimate multiplies the number of just-noticeable steps in hue by those in saturation and lightness. Different assumptions about each produce answers ranging from around a million to well over ten million, and the widely repeated figure is one plausible result rather than a settled fact. It also describes discriminable pairs seen side by side under good conditions — not colours anyone could name, remember or match from memory, which is a far smaller number.
People can distinguish two very similar colours placed edge to edge far more reliably than they can identify either one alone, and colour memory is poorer still. English has around eleven basic colour terms in common use, and most people can name a few hundred colours at most with any confidence. The gap between roughly ten million discriminable colours and a few hundred nameable ones is why colour codes exist, and why 'I'll know it when I see it' is a reasonable thing to say about paint.
It is also why matching a colour from memory in a shop so often goes wrong, and why decorators insist on physical samples.
Discrimination depends heavily on light level, on the size of the patches being compared, on whether they touch, and on what surrounds them. In dim light, cone contribution falls and discrimination collapses towards none. Very small samples are harder to distinguish than large ones. A gap between two patches makes the comparison markedly harder than an edge. Any single number for 'colours humans can see' is therefore an average across conditions that vary enormously.
A minority of people carry a fourth cone type with sensitivity between the usual ones. Whether this translates into genuinely richer colour discrimination is not straightforward and appears to depend on how the extra signal is processed; documented cases of measurably enhanced discrimination are rare. It is a real area of research rather than a settled capability, and claims that a particular person 'sees a hundred million colours' should be treated with caution.
Wavelength ranges and perceptual thresholds are given as approximations: both vary between individuals and with viewing conditions, and sources differ on exact boundaries. Where a figure is contested or unavailable, this page says so rather than picking one.