News for hackers. Stuff that matters.
Re:Prime Number Grid by throw310822 on Tuesday August 19, 2025 @03:58AM (#44949321)
Kind of surprising, my intuitive idea of primes is that they become rarer much faster, while there's really a ton of them.
Re:Prime Number Grid by susam on Tuesday August 19, 2025 @04:04AM (#44949371)
They indeed do become rarer. Plotting all the primes in a single row makes this apparent, like so: https://susam.net/primegrid.html#1-1-1000000

In fact, according to the celebrated prime number theorem, the number of primes less than or equal to n is asymptotic to n/log n, which means the density of primes near n is asymptotic to 1/log n.

I have a small section about this at https://susam.net/journey-to-prime-number-theorem.html#prime... if you want to read more about this.

See also: https://en.wikipedia.org/wiki/Prime_number_theorem

Re:Prime Number Grid by eru on Tuesday August 19, 2025 @04:47AM (#44949589)
Yes.

> In fact, according to the celebrated prime number theorem, the number of primes less than or equal to n is asymptotic to n/log n, which means the density of primes near n is asymptotic to 1/log n.

When written down as a string of digits, log n is another way to say 'proportional to the number of digits'.

The number of digits grows fairly slowly, thus also the 'probability' of a number being prime drops very slowly.

Re:Prime Number Grid by kristopolous on Tuesday August 19, 2025 @04:05AM (#44949385)
This is a very well researched topic

https://en.m.wikipedia.org/wiki/Prime_number_theorem

Re:Prime Number Grid by Someone on Tuesday August 19, 2025 @04:22AM (#44949470)
That’s what ‘everybody’ thinks. I think that’s from reading so much about them being hard to find. They aren’t hard to find, though, it’s (as far as we know) hard to recognize integers as being primes.

There are more prime numbers than there are squares of integers.

Re:Prime Number Grid by throw310822 on Tuesday August 19, 2025 @05:04AM (#44949669)
> I think that’s from reading so much about them being hard to find

More from the fact that each prime number makes all its multiples non-prime, so you'd expect this would accumulate quickly in making primes an increasingly rare find. Which is the case, but slower than intuition suggests.

Re:Prime Number Grid by eru on Tuesday August 19, 2025 @04:48AM (#44949596)
> They aren’t hard to find, though, it’s (as far as we know) hard to recognize integers as being primes.

Depends on what you mean by 'hard'. It's easy in the sense that we have algorithms to decide whether a number is prime or composite that take time polynomial in the space it takes to write down your number (ie polynomial in log n).

Re:Prime Number Grid by knome on Tuesday August 19, 2025 @08:19AM (#44950748)
>There are more prime numbers than there are squares of integers.

all integers have a square, while not all integers are prime.

in any given span, you'll see more primes than squares, however.

more dense?

Re:Prime Number Grid by SamBam on Tuesday August 19, 2025 @10:33AM (#44951995)
They must both have the same cardinality, ℵ0, because they are both infinite subsets of the natural numbers, and so can each be laid out in order and paired with every natural number.
Re:Prime Number Grid by madcaptenor on Tuesday August 19, 2025 @08:53AM (#44950964)
For example, the number of primes less than n is around n/log(n) while the number of squares less than n is around sqrt(n), which is much smaller.
Re:Prime Number Grid by Someone on Wednesday August 20, 2025 @03:52PM (#44965697)
> all integers have a square, while not all integers are prime.

That’s true, but I don’t see how that’s an argument. “All integers have a prime ‘the nth prime’, while not all integers are squares” similarly is true, but not an argument as to which set is denser.