Refacte monogramRefacte

Mathematics / Number theory

Extracting the First Prime Greater than m

Elementary number theory, factorials, and divisibility.

In this exposition

The mechanism

Build an exact arithmetic selector

Turn a test for primality into arithmetic that selects the first prime above a bound. Factorial congruences, greatest common divisors, and valuations organise the selection. The construction is useful here because each stage has an exact role in isolating the answer.

What becomes elementary: The desired selection is expressed by a finite formula, with its correctness separated from questions of computational efficiency.

Track what each arithmetic test retains. The study is an exact construction; it does not claim a practical improvement over prime-search algorithms.

Explore further constructions. Edition dates, sources and reference chapters identify the scope of each study.

Abstract

For an integer , define

Let be the largest nonnegative integer such that . We prove that

is the smallest prime greater than . The construction has two stages: first isolates exactly the primes in the interval , and then the factorial distinguishes the smallest of those primes by giving it the largest valuation.

Introduction

This problem was mentioned to me on IRC. The following argument explains why the construction works: one stage isolates a finite set of primes, and the other uses factorial valuations to distinguish its smallest member.

There are two separate filters in the formula. The first filter is

The factor prevents primes larger than from appearing, while the congruence condition modulo prevents primes at most from appearing. What remains is precisely the set of primes strictly between and .

A number line marked 1, m, and 2m: primes at most m divide m factorial and cannot divide (m factorial) to the power m factorial minus one; primes strictly between m and 2m are exactly the prime factors of d; primes above 2m are too large to divide (2m) factorial.
Figure 1: The first gcd filters primes according to their position relative to m.

The second filter is more subtle. Once has been shown to be a squarefree product

the number gives each prime factor the same exponent . Dividing by subtracts the exponent with which appears in . Smaller primes appear more often in , so the smallest prime is the one whose exponent is reduced the most. The definition of then removes the common remaining power of , and the final gcd detects which primes are still present. Exactly one prime has disappeared: .

Statement

Theorem 1. Let be an integer. Define

Let be the largest nonnegative integer such that . Then

is the smallest prime greater than .

Proof

For a prime and a positive integer , write for the exponent of in the prime factorization of .

We shall use Bertrand’s postulate in the following form: for every integer , there is a prime such that

For completeness, an elementary proof of this fact is included in the appendix.

Lemma 1 (The first gcd)

Let

Then

In particular, is squarefree and .

Proof. First suppose that a prime divides . Since , we have . On the other hand, , because if , then

which is incompatible with . Therefore . Since , the endpoint is composite, so . Hence

Thus every prime divisor of lies in .

Conversely, let . We prove that . Since , the prime does not divide . Hence Fermat’s little theorem gives

It remains to know that the exponent is compatible with this congruence.

Except for the small case , one has

Indeed, write

If , then or . The case gives , while the case is the exceptional case just mentioned. If , then , and from we get . Thus and are distinct factors occurring in , so

Therefore, outside the exceptional case,

In the exceptional case , we have , so again

Thus in every case .

Also , since . Hence . Moreover, because , we have , so occurs exactly once in . Consequently occurs exactly once in .

We have shown that the prime divisors of are exactly the primes in , each with exponent . Hence

Finally, Bertrand’s postulate ensures that is nonempty, so .

Now list the primes in in increasing order:

By the lemma,

Here .

Lemma 2 (The exponent filter)

For each , set

Then

whenever . Consequently, if

then the largest nonnegative integer such that is

Proof. Since is squarefree, the exponent of in is exactly . Also

Because , we have , and therefore

Hence the exponent of in is exactly , and so

It remains to compare the numbers . If , then , so for every positive integer ,

For , the inequality is strict, since and are integers and

Thus . In particular,

when .

Let

Then

and the inequalities among the reverse to give

when . Since is squarefree, exactly when every exponent is at least . Therefore the largest possible is

The same formula is also valid when , where the minimum consists of the single exponent .

We can now finish the proof of the theorem. By the preceding lemma,

Therefore

The exponent of in this product is , while for every , the exponent of is positive. Hence

where the empty product is interpreted as when . It follows that

By construction, is the smallest prime in the interval . Bertrand’s postulate ensures that the least prime greater than lies in this interval. Therefore is the smallest prime greater than , as claimed.

Appendix: Bertrand’s Postulate

For completeness, we include a standard elementary proof of the form of Bertrand’s postulate used above.

Lemma 3

For every real number ,

where the product is over primes .

Proof. It suffices to prove the claim for positive integers , since replacing by can only decrease the left-hand side.

We prove the integer case by strong induction on . The cases are immediate. Suppose the result is known for all positive integers smaller than .

First let . The product of the primes with divides the binomial coefficient . Hence

Now let . The product of the primes with divides . Also

The central coefficient is at most half of the sum of all coefficients in the -th row of Pascal’s triangle; indeed, the two adjacent coefficients already have sum at least . Therefore

and hence . Using the induction hypothesis at , we get

This completes the induction.

Proposition 1 (Bertrand’s postulate)

For every integer , there is a prime such that

Proof. Let

We first prove that for . Since the central binomial coefficient is the largest coefficient in the expansion of , we have

Now factor into primes. For a prime , write . If , then each summand in

is at most , so . The total contribution from primes is therefore at most .

If , then only the first summand can be nonzero. Moreover, for , one has

so such primes do not divide . Hence

By the previous lemma,

Combining these inequalities gives

For , set

Then

The last two terms decrease in magnitude as increases, and a direct calculation gives

Thus for all . Equivalently,

for every integer . Hence , so there is a prime with . Since is composite for , this prime satisfies .

It remains only to check . The following table covers all such ; in each row, the displayed number is prime and satisfies throughout the indicated range.

range of covered by

This proves Bertrand’s postulate for every integer .