For n∈N+, let π(n) be the number of prime numbers that are ≤n. The prime number theory states that
nlimπ(n)nlnn=1.
We show here a weaker version in which
nπ(n)=Θ(logn1).
It states that the density of the prime numbers in [1,n] is Θ(1/log2n), which is inversely proportional to the number of bits required to represent n.
Theorem. For 3≤n∈N+, it holds that
2log2n1≤nπ(n)≤lnn2
For the first inequality, we will show that ∀k∈[n],
(kn)≤nπ(n).
Roughly speaking, the prime factorization of (kn) consists of at most π(n) different primes ≤n. The inequality follows if we can prove that the highest power of a prime in the factorization is at most n. We can choose k=⌊n/2⌋ to maximize the lower bound.
For the second inequality, we use
(k+2)π(2k+1)−π(k+1)≤(k2k+1)
for k∈N+ and upper bound (k2k+1) by 22k. We only consider odd numbers 2k+1 here because π(2k+2)=π(2k+1),∀k∈N+.
Proof of The Theorem, Part 1.
We need a few lemmas for the proof.
Definition. Given a prime number p and n∈N+, mp(n) is the number of large integer k such that pk divides n.
Lemma 1.
mp(n!)=j=1∑∞⌊pjn⌋
Proof. We count the number of time p divides n!. Each multiple of p that is in [n] contributes a factor. Each multiple of p2 that is in [n] contributes another factor, and so on.
□
Lemma 2.
Let a,b∈N+, a>b>0. Given a prime p and an integer k∈N+, if pk divided (ba), then pk≤a.
Proof. Let k′=mp((ba)). It suffices to show that pk′≤a.
Each summand is either 1 or 0. Further, when pj>a (i.e., j>logpa), the summand is 0. It concludes that k′≤logpa.
□
Lemma 3.
(⌊n/2⌋n)≤nπ(n)
Proof. Consider the unique prime factorization of (⌊n/2⌋n),
(⌊n/2⌋n)=p1k1p2k2...ptkt,
where pi=pj, for 1≤i<j≤t. By Lemma 2 we have ∀i∈[t], piki≤n and pi is a prime number at most n. Hence t≤π(n). It follows that
(⌊n/2⌋n)=p1k1p2k2...ptkt≤nt≤nπ(n).
□
Lemma 4.
n+112n≤(⌊n/2⌋n)≤nπ(n)
Proof. Given n∈N+, as (kn) is maximized when k=⌊n/2⌋ for (k=0,1,2,...,n), it holds that
1=(21+21)n≤(n+1)2n1(⌊n/2⌋n).
This establishes the lower bound.
□
By Lemma 4,
π(n)≥lognn−log(n+1)≥21lognn.
The final inequality holds when log(n+1)≤0.5n. It suffices to take n≥7, as log(7+1)=3<3.5 but log(3+1)=2>1.5. When n<7, we can check manually that π(n)/n≥0.5/logn holds.
■
Proof of The Theorem, Part 2.
Lemma 5.
For k∈N+,
(k2k+1)≥k+2≤p≤2k+1∧p is prime∏p
Proof.
First,
(k2k+1)=k(k−1)...1(2k+1)(2k)(2k−1)...(k+2).
For a prime p∈[k+2,2k+1], it divides the numerator but not the denominator.
□
We prove that π(n)≤2n/lnn by induction. When n>2 is even, π(n)=π(n−1). As 2n/lnn increases with n, it suffices to prove this for odd numbers of n. Suppose that n=2k+1 for some k∈N+, then
(k+2)π(2k+1)−π(k+1)≤k+2≤p≤2k+1∧p is prime∏p≤(k2k+1).