DevTools Hub

Search tools

Search for a developer tool

Algorithms

Big O Calculator

Compare O(1), O(log n), O(n), O(n log n), and O(n²) at real input sizes.

Part of the Algorithms Toolkit
n = 100
O(1)
1
O(log n)
7
O(n)
100
O(n log n)
665
O(n²)
10,000
n = 1,000
O(1)
1
O(log n)
10
O(n)
1,000
O(n log n)
9,966
O(n²)
1,000,000
n = 10,000
O(1)
1
O(log n)
14
O(n)
10,000
O(n log n)
132,878
O(n²)
100,000,000
nO(1)O(log n)O(n)O(n log n)O(n²)
1001710066510,000
1,0001101,0009,9661,000,000
10,00011410,000132,878100,000,000

What this calculates

Enter one or more input sizes (n) and see the actual operation count for five common complexity classes — O(1), O(log n), O(n), O(n log n), and O(n²) — side by side, as both a log-scale bar chart and an exact-value table. The point isn't just seeing the formulas; it's seeing how fast they pull apart from each other as n grows, which is much easier to feel with real numbers than with the notation alone.

Why the bars are log-scaled

At n = 10,000, O(log n) is around 13 and O(n²) is 100,000,000 — a linear bar chart would render every class except O(n²) as an invisible sliver. The bar width here is proportional to log₁₀(value) instead, which keeps every class visually readable at once. The exact value is always shown next to the bar and in the table below, so the log scale never hides the real number — it only affects how the comparison looks.

The formulas, exactly

Every value is rounded up to the next whole number, since a fractional number of operations isn't meaningful — an actual algorithm doesn't perform 6.64 steps, it performs 7.

FAQ

I want to see these as continuous growth curves, not a table

Complexity Visualizer plots these classes — plus O(2ⁿ), which this tool doesn't cover — as continuous curves on an interactive chart that rescales as you drag the input size up.

Why does the table switch to scientific notation for large numbers?

Once a value passes a billion, a full digit string (like 100,000,000,000,000) gets hard to read at a glance — this switches to 1.00 × 10^14 above that point purely for readability. Nothing about the underlying calculation changes.

What's the maximum n I can enter?

10,000,000. Beyond that, O(n²) starts producing numbers large enough that the comparison stops being informative — the point of this tool is building intuition for how these classes diverge, not stress-testing floating point.

Where do these classes actually come from?

See Algorithm Complexity Explained for the formal definitions of Big O, Big Theta, and Big Omega, why best/worst/average case is a separate question from which notation you use, and real examples of algorithms that fall into each of these five classes.

Is anything I enter sent anywhere?

No — every calculation happens entirely in your browser. Nothing you enter here is ever sent to a server.

Related tools