35

Consider the multiplication table for the numbers $1,2,\dots, n$. How many different numbers are there? That is, how many different numbers of the form $ij$ with $1 \le i, j \le n$ are there?

I'm interested in a formula or an algorithm to calculate this number in time less than $O(n^2)$.

Tony Huynh
  • 31,500
falagar
  • 2,761
  • 3
    A nice paper on this with plenty of references: Multiples and Divisors, by Steven Finch, available online from CiteSeer. – Sidney Raffer Jul 13 '10 at 06:04
  • 2
    If all you can hope to save is a fractional power of $\log n$ then you ought to keep track of powers of $\log n$ in the computation model and complexity estimates; and then, even if you use repeated addition rather than multiplication to get each row of the multiplication table, the direct method seems to take $n^2 \log n$ time and space if you count honestly (i.e. $\log n$ bits for a number of size $n$). – Noam D. Elkies Oct 18 '13 at 03:58
  • 3
    Related: http://mathoverflow.net/questions/108912/number-of-elements-in-the-set-1-cdots-n-times-1-cdots-n/108939#108939 – Eric Naslund Dec 09 '13 at 15:49

3 Answers3

29

This is the multiplication table problem of Erdos. According to Kevin Ford, Integers with a divisor in $(y,2y]$, Anatomy of integers, 65-80, CRM Proc. Lecture Notes, 46, Amer Math Soc 2008, MR 2009i:11113, the number of positive integers $n\le x$, which can be written as $n=m_1m_2$, with each $m_i\le\sqrt x$, is bounded above and below by a constant times $x(\log x)^{-\delta}(\log\log x)^{-3/2}$, where $\delta=1-(1+\log\log2)/\log2$.

Erdos' work on this problem can be found (in Russian) in An asymptotic inequality in the theory of numbers, Vestnik Leningrad Univ. Mat. Mekh. i Astr. 13 (1960) 41-49.

Another reference is http://oeis.org/A027424 where a PARI program is given.

xan
  • 103
Gerry Myerson
  • 39,024
  • 3
    Thank you for references!

    The PARI program implements straightforward $O(n^2)$ algorithm. Is there any algorithm which works faster than $O(n^2)$?

    – falagar Jul 13 '10 at 08:43
  • 1
    Ford's Annals of Mathematics preprint is on the arXiv: http://arxiv.org/abs/math/0401223 – Charles Jul 22 '10 at 04:35
  • @GerryMyerson "the number of positive integers $n\le x$, which can be written as $n=m_1m_2$, with each $m_i\le\sqrt x$, is bounded above and below by a constant times $x(\log x)^{-\delta}(\log\log x)^{-3/2}$, where $\delta=1-(1+\log\log2)/\log2$". That bound is asymptotic bound. Is there a minimum $x$ needed for that bound to be effective? – VS. May 05 '20 at 17:18
  • 1
    @VS. I don't know. Have you looked at the paper to see how the bound is expressed there? – Gerry Myerson May 05 '20 at 22:52
12

There's a beautiful lecture by Carl Pomerance in which he discusses Erdos's Multiplication Table Problem and then goes on to talk about dense product-free sets of integers. The talk was at the JMM in Boston in 2012. It's available at

https://math.dartmouth.edu/~carlp/sumproductboston.pdf

Joe Silverman
  • 45,660
6

Regarding the algorithmic question, a recent paper of Brent, Pomerance, Purdum, and Webster presents a subquadratic algorithm to compute the number of distinct products $M(n)$ of the $n \times n$ multiplication table. They have implemented their results to compute $M(n)$ exactly for all $n \leq 2^{30}$. They note that for larger values of $n$, exact algorithms become impractical, and so the paper also presents two Monte Carlo algorithms to approximate $M(n)$. Monte Carlo computations are presented for $n$ up to $2^{100000000}$.

Tony Huynh
  • 31,500