Primality Testing: Divisibility Analysis & $\sqrt{N}$ Upper Bound
1. Core Principles & Theoretical Framework
2. Mathematical Formulation & Algorithmic Pipeline
Mathematical proof of divisor bounding:
3. Numerical Mechanics & Implementation Logic
- Base Cases: If $N \le 1$, return
False. If $N \in \{2, 3\}$, returnTrue. If $N$ is even or $N \pmod 3 == 0$, returnFalse. - Wheel Factorization: Test potential factors $d = 6k \pm 1$ up to $\lfloor\sqrt{N}\rfloor$, stepping by 6 to skip multiples of 2 and 3.
- Computational Complexity: Reduces trial division steps from $\mathcal{O}(N)$ down to $\mathcal{O}(\sqrt{N})$.
4. Relevant Computational Practice Exercises
- Donald E. Knuth, "The Art of Computer Programming, Vol. 2: Seminumerical Algorithms", Addison-Wesley (1997).