Live data from Hacker News

Only 17% of all 64-bit Integers are products of two 32-bit integers

lemire.me

71–80 of 115 posts

Re: Only 17% of all 64-bit Integers are products of two 32-bit integers

#71

There is a cute argument (I think it is due to Erdos) that, asymptotically, 0% of the integers in [0,n^2] appears in the "n by n multiplication table": By Erdos-Kac, almost all integers of size about n^2 have about log(log(n^2)) ~ log(log(n)) prime factors. However, almost all integers in the multiplication table have about 2*log(log(n)) prime factors. Kevin Ford gets much more precise asymptotic estimates.

They address this argument in the blog.

Re: Only 17% of all 64-bit Integers are products of two 32-bit integers

#72
post #13

Earlier quoted context omitted.

There are about 18.446 quintillion more 64-bit integers than 32-bit integers.

True, but there are as many 64-bit integers as pairs of 32-bit integers. Therefore the fact that relatively few 64-bit numbers are products of 32-bit integers means that a lot of pairs of 32-bit integers give by multiplication the same product.

That seems intuitively true given that most 32-bit numbers are composite, so if you have

X = ab and aY X × Y = X/a × aY = X/b × bY = Y × X = aY × X/a = bY × X/b

Which is 6 pairs resulting in the same product. This will be reduced if e.g. aY = X, but still...

Re: Only 17% of all 64-bit Integers are products of two 32-bit integers

#74
post #51
post #6

Earlier quoted context omitted.

All the primes above 2^32 are out, but that accounts for only two point something percent.

But also all of their multiples. I suspect that those account for the vast majority.

Each x is prime with probability 1/ln(x), each x has M/x multiples less than M, as a fraction of M that is just 1/x. Together that makes 1/(x ln(x)) with the indefinite integral ln(ln(x)). If we plug in 2^32 and 2^64 [1], we get ln(2). So about 69.3 % of all 64 bit integers should have a prime factor larger than 2^32 and therefore not be the product of two 32 bit integers. That leaves about 13 % unaccounted. Three prime factors all larger than 2^32/2, five prime factors all larger than 2^32/3, and so on cannot be packed into two 32 bit integers. Not sure to how much this will add up.

[1] The bounds are important because they guarantee that there is at most one prime factor from that range and this ensures that we are not double counting anything. If the upper bound was larger than the square of the lower bound, then we would have to worry about double counting numbers with more than one large prime factor.

Re: Only 17% of all 64-bit Integers are products of two 32-bit integers

#76

> I find it interesting to consider that if you pick a value at random, it will usually fail! That is, most 64-bit integers cannot be written as the product of two 32-bit integers. While I find the 17% number interesting to think about, "most" is far less interesting. Multiplication doesn't care about order so you're instantly cutting 2^64 possibilities down to about 2^63. That's a hair's breadth away from "most" alr…

Ok so I think I understand your insight: the number of 64 bit numbers you can get from multiplying two 32 bit numbers is the number of distinct results. I guess it follows that, of those 64 bit integers that can be written as the product of 2 32 bit ints, on average they can be factored into 32 bit ints 6 different ways. The only ones that could possibly be written as such a product exactly one way are the prefect squares.

Re: Only 17% of all 64-bit Integers are products of two 32-bit integers

#79
post #74
post #51

Earlier quoted context omitted.

But also all of their multiples. I suspect that those account for the vast majority.

Each x is prime with probability 1/ln(x), each x has M/x multiples less than M, as a fraction of M that is just 1/x. Together that makes 1/(x ln(x)) with the indefinite integral ln(ln(x)). If we plug in 2^32 and 2^64 [1], we get ln(2). So about 69.3 % of all 64 bit integers should have a prime factor larger than 2^32 and therefore not be the product of two 32 bit integers. That leaves about 13 % unaccounted. Three pr…

Nice work. I guess "vast majority" is overstating the case, but majority anyway.
Post reply on HN