How many Grover iterations should you run?

The best count, why more is not better, and what to do when you do not know how many answers exist.

8 min read · reviewed December 2026

The formula

With N items and M correct answers, the best number of iterations is the whole number nearest to π/(4θ) − 1/2, where θ = arcsin(√(M/N)). For M much smaller than N this is close to (π/4)·√(N/M).

k ≈ π / (4θ) − 1/2

k ≈ (π/4)·√(N/M) when M ≪ N

Success probability for small searches

The success table is computed from the exact formula. Notice that N = 4 reaches 100 percent after one iteration, N = 8 never reaches 100 percent, and the probability always falls after the optimum.

N = 4 items, 1 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
025.0%plain guess
1100.0%best count
225.0%overshoot
325.0%overshoot
4100.0%overshoot

Eight items

N = 8 items, 1 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
012.5%plain guess
178.1%
294.5%best count
333.0%overshoot
41.2%overshoot
554.8%overshoot

Sixteen items

N = 16 items, 1 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
06.3%plain guess
147.3%
290.8%
396.1%best count
458.2%overshoot
512.5%overshoot
62.0%overshoot

What happens at larger sizes

As N grows, the best success probability gets closer to 1, because each rotation step is smaller and the state can land closer to the target. For one correct answer among about a million items (2²⁰ = 1,048,576), the best iteration count is 804 and the success probability is within a fraction of a percent of 100. You can check this in the scale table in the lab.

When you do not know how many answers there are

In real problems you often do not know M. If you guess too many iterations you overshoot. Boyer, Brassard, Høyer and Tapp showed a simple fix in 1996: run the algorithm with a randomly chosen number of iterations, drawn from a range that grows geometrically between rounds. The expected number of oracle calls stays on the order of √(N/M) even though M is unknown.

There is also a quantum counting method, based on phase estimation, that estimates M first. It costs additional √N-type effort, so the randomised method is often simpler.

The exact constants in these methods depend on the variant used. Check the original papers before relying on a specific number.

A practical recipe

  • If you know M, use the formula and run the optimal count once.
  • If you know a rough range for M, run a few rounds with different counts and check each result with the classical checker.
  • If you know nothing, use the randomised schedule from Boyer et al.
  • Always verify the output with the checker, because a measurement is a sample and not a proof.

Try it

Questions

Can I run just one extra iteration to be safe?

No. Past the optimum the probability falls. For N = 8 the third iteration drops success from about 94.5 percent to about 33 percent.

Does Grover ever give exactly 100 percent?

Only in special cases, such as N = 4 with one answer, or when the angle works out evenly. Variants with an adjusted final rotation can make it exact, at the cost of a more complex circuit.

Read next

Sources and further reading