Live data from Hacker News

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

lemire.me

61–70 of 115 posts

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

#61

This just seems like an expansion of prime numbers to includes factors in the 2^33+ range. Basically you're calculating if a number is prime but stopping the check when the factors go above 2^32.

Well, technically yes, but 'stopping the factors at 32 bits' is a plenty interesting constraint because it excludes all 64 bit composite numbers that have at least one factor above 2^32.

You have to redo the math to make the constraint work.

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

#63
post #14
post #2

I dream of a future where all 64-bit integers are products of 32-bit integers. Together, we can change math for the better.

1 + 1 = 3 (for sufficiently large values of 1)

I thought you were making a joke but if we're assuming that the 1's are being rounded or truncated before the final value cake is produced I guess you are right.

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

#65
> You might be able to come up with a more efficient algorithm.

Challenge accepted. Suppose we want to know the answer to 3 decimal places (so we'd match the headline). And suppose I allow my algorithm to be wrong one in a thousand times ("probably approximately correct").

Then sample some constant number C of random 64 bit integers. Run the following algorithm which separates each random sample into one of three classes: Y (has 32 but factors), N (does not have 32 bit factors), U (unknown).

Check if prime using probabilistic miller rabin. (Error prob goes to zero exponentially fast). If prime, return N. If it's not a prime, then run T steps of pollard rho to determine whether the number has 32 but factors; return Y,N, or U depending of the factors found up to step T.

The key observation is that T can be chosen to make the UNKNOWN class very small (with high probability), and so our estimate should rapidly converge to 17%Y, 83%N, ~0.001%U

For fixed error tolerance, this would run in roughly a constant number of iterations, independent of N.

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

#66

This just seems like an expansion of prime numbers to includes factors in the 2^33+ range. Basically you're calculating if a number is prime but stopping the check when the factors go above 2^32.

Having a prime factor greater than 2^32 accounts for about 80% of the 64-bit integers that can’t be expressed as a product of 32-bit integers. But it’s not the only way; you can also have three prime factors in the range (2^16, 2^32), for instance.

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

#67
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.

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

#68
post #58

Earlier quoted context omitted.

Why does order matter? Whether a 64-bit number can be written as the product of two 32-bit ones depends only on the prime factors of the 64-bit number - it's a property of the number itself, and apparently 17% of 64-bit numbers have this property.

The input space is 32 + 32 = 64 bits. The output space is 64 bits. So the best you can do is an 1-to-1 mapping. However, since a * b = b * a, our input space has a lot of duplicate outputs. So from this alone you can conclude roughly half of the output space must be uncovered by any input pair, simply because there aren't enough input pairs.

OK - thanks. I must have misunderstood what the other poster was saying, since I thought they were objecting to the "most" characterization.

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

#69

> You might be able to come up with a more efficient algorithm. Challenge accepted. Suppose we want to know the answer to 3 decimal places (so we'd match the headline). And suppose I allow my algorithm to be wrong one in a thousand times ("probably approximately correct"). Then sample some constant number C of random 64 bit integers. Run the following algorithm which separates each random sample into one of three cla…

Even if you have 32-bit factors the number may not be the product of two 32-bit numbers. For example 2^62*3 cannot be split as either (2^32, 2^30*3) or (2^31, 2^31*3). In both cases one factor does not fit in 32 bits.

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

#70

This just seems like an expansion of prime numbers to includes factors in the 2^33+ range. Basically you're calculating if a number is prime but stopping the check when the factors go above 2^32.

Having a prime factor greater than 2^32 accounts for about 80% of the 64-bit integers that can’t be expressed as a product of 32-bit integers. But it’s not the only way; you can also have three prime factors in the range (2^16, 2^32), for instance.

More precisely one in the range (a,2^32) and two in the range (2^32/a, 2^32). But if the latter have many duplicate prime factors it's worse.
Post reply on HN