Prime Search Near a Threshold: Next & Previous Prime Algorithms
1. Core Principles & Theoretical Framework
2. Mathematical Formulation & Algorithmic Pipeline
Prime gap $\Delta_p$ and Bertrand's Postulate guarantee:
3. Numerical Mechanics & Implementation Logic
- Search Direction: To find next prime, set candidate $c = N + 1$ (or $N + 2$ if $N$ is odd); increment by 2.
- Primality Sub-Check: Apply the $\mathcal{O}(\sqrt{c})$ primality test to each candidate.
- Termination: Break and return the first candidate satisfying primality criteria.
4. Relevant Computational Practice Exercises
- G. H. Hardy and E. M. Wright, "An Introduction to the Theory of Numbers", Oxford University Press (2008).