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.
| Iterations k | Chance of a marked result | Note |
|---|---|---|
| 0 | 25.0% | plain guess |
| 1 | 100.0% | best count |
| 2 | 25.0% | overshoot |
| 3 | 25.0% | overshoot |
| 4 | 100.0% | overshoot |
Eight items
| Iterations k | Chance of a marked result | Note |
|---|---|---|
| 0 | 12.5% | plain guess |
| 1 | 78.1% | |
| 2 | 94.5% | best count |
| 3 | 33.0% | overshoot |
| 4 | 1.2% | overshoot |
| 5 | 54.8% | overshoot |
Sixteen items
| Iterations k | Chance of a marked result | Note |
|---|---|---|
| 0 | 6.3% | plain guess |
| 1 | 47.3% | |
| 2 | 90.8% | |
| 3 | 96.1% | best count |
| 4 | 58.2% | overshoot |
| 5 | 12.5% | overshoot |
| 6 | 2.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
- L. K. Grover, “A fast quantum mechanical algorithm for database search” (1996)
- C. Bennett, E. Bernstein, G. Brassard, U. Vazirani, “Strengths and weaknesses of quantum computing” (1997)
- M. Boyer, G. Brassard, P. Høyer, A. Tapp, “Tight bounds on quantum searching” (1996/1998)
- G. Brassard, P. Høyer, M. Mosca, A. Tapp, “Quantum amplitude amplification and estimation” (2002)
- R. Babbush et al., “Focus beyond quadratic speedups for error-corrected quantum advantage” (2021)
- M. Nielsen and I. Chuang, Quantum Computation and Quantum Information, chapter 6