Academy
MathsNumber TheoryDirichletThe Multiplication Table Median

The Multiplication Table Median

If you sort all entries of an n×n multiplication table, the median is not near n²/2. It is much smaller. The reason is the hyperbola — and it makes the Dirichlet divisor problem concrete.

Take a 61×6161 \times 61 multiplication table. It has 37213721 entries. What is the median — the 1861st value when all entries are sorted?

Most people guess somewhere near 18001800 — roughly half of 37213721, the maximum entry.

The actual median is 779\mathbf{779}.

Less than a quarter of the way up the range. Why?


Setting up the question

The entries of an n×nn \times n multiplication table are the products {ij:1i,jn}\{i \cdot j : 1 \leq i, j \leq n\}.

There are n2n^2 entries in total (with repetitions). The median is the value MM such that exactly half the entries satisfy ijMi \cdot j \leq M.

So we need: how many pairs (i,j)(i, j) with 1i,jn1 \leq i, j \leq n satisfy ijMij \leq M?

Call this count f(M)f(M). We want the smallest MM such that f(M)n2/2f(M) \geq n^2/2.


The count is a lattice point problem

f(M)f(M) is the number of lattice points (i,j)(i, j) with 1i,jn1 \leq i, j \leq n and ijMij \leq M.

For Mn2M \leq n^2, this is the number of integer pairs inside the rectangle [1,n]×[1,n][1,n] \times [1,n] that also lie below the hyperbola y=M/xy = M/x.

f(M)=i=1nmin ⁣(n, Mi)f(M) = \sum_{i=1}^{n} \min\!\left(n,\ \left\lfloor \frac{M}{i} \right\rfloor\right)

For small ii (where M/i>nM/i > n), the constraint is just jnj \leq n — all nn values work. For large ii (where M/i<nM/i < n), the constraint is jM/ij \leq M/i.

The crossover happens at i=M/ni = M/n.


Why the median is small

The hyperbola ij=Mij = M is dense near the axes. When ii is small, jj can be as large as M/iM/i — many pairs. When ii is large, jj is forced small.

The "density" of lattice points is not uniform across the rectangle. It clusters near the edges where one coordinate is small.

Because of this clustering, you reach half the table's entries at a value MM far below n2/2n^2/2.

Rough estimate. The total number of pairs with ijMij \leq M is approximately (from the hyperbola area):

f(M)Mln ⁣(n2M)+lower orderf(M) \approx M\ln\!\left(\frac{n^2}{M}\right) + \text{lower order}

Setting f(M)=n2/2f(M) = n^2/2 and solving gives Mn2/(2lnn)M \approx n^2 / (2\ln n) roughly — much smaller than n2/2n^2/2.

For n=61n = 61: n2=3721n^2 = 3721, ln614.11\ln 61 \approx 4.11, giving M3721/8.22453M \approx 3721/8.22 \approx 453. The true answer 779 is in the right ballpark — the rough estimate is off because the formula needs more terms, but the order of magnitude is correct.


The exact computation

To find the exact median for a given nn:

  1. For each candidate MM, compute f(M)=i=1nmin(n,M/i)f(M) = \sum_{i=1}^{n} \min(n, \lfloor M/i \rfloor).
  2. Binary search on MM in [1,n2][1, n^2] until f(M)n2/2f(M) \geq n^2/2 and f(M1)<n2/2f(M-1) < n^2/2.

The binary search takes O(logn2)=O(logn)O(\log n^2) = O(\log n) steps. Each evaluation of f(M)f(M) takes O(n)O(n) steps. Total: O(nlogn)O(n \log n).

For n=61n = 61, this is fast. For large nn, the hyperbola-splitting trick from Counting Lattice Points reduces each evaluation to O(M)O(\sqrt{M}).


What this reveals about multiplication tables

The median being at n2/(clogn)\sim n^2 / (c \log n) rather than n2/2n^2/2 has a concrete interpretation:

Most products in the table are small. The multiplication table is not a uniform sample from [1,n2][1, n^2]. Numbers near 1 are overrepresented (many pairs (i,j)(i, j) give small products), while numbers near n2n^2 are underrepresented (only the pair (n,n)(n, n) gives the maximum).

This is the same skewness that makes the average number of divisors grow like lnn\ln n — both come from the hyperbola's shape.


Worked problems

Problem 1. In a 10×1010 \times 10 multiplication table, how many entries are 20\leq 20?

Count pairs (i,j)(i,j) with 1i,j101 \leq i,j \leq 10 and ij20ij \leq 20:

For each ii: jmin(10,20/i)j \leq \min(10, \lfloor 20/i \rfloor).

ii20/i\lfloor 20/i \rfloormin(10,)\min(10, \cdot)
12010
21010
366
455
544
633
722
822
922
1022

Total: 10+10+6+5+4+3+2+2+2+2=4610+10+6+5+4+3+2+2+2+2 = 46.

So 46 out of 100 entries are 20\leq 20. The median is slightly above 20.

Problem 2. Estimate the median of a 100×100100 \times 100 multiplication table.

n=100n=100, n2=10000n^2 = 10000. Rough estimate: Mn2/(2lnn)=10000/(2×4.605)1086M \approx n^2/(2\ln n) = 10000/(2 \times 4.605) \approx 1086.

The true median is around 1369. Again the estimate captures the right scale — much less than 5000.

Problem 3. Prove that at least nn distinct values appear in an n×nn \times n multiplication table.

The entries 1×1,1×2,,1×n1\times 1, 1\times 2, \ldots, 1\times n are nn distinct values: 1,2,,n1, 2, \ldots, n. \blacksquare

(The actual number of distinct values is much larger — a result of Erdős and others.)


The full asymptotic expansion of D(n)=k=1nτ(k)D(n) = \sum_{k=1}^n \tau(k) — which underlies all of this — is the content of Dirichlet's Divisor Problem.