Smallest Divisor Above One — Solution & Editorial
Trial division from 2 to √N; the first hit is the answer, and no hit means N is prime.
Complexity: O(√N)
Trial division from 2 to √N; the first hit is the answer, and no hit means N is prime.
Complexity: O(√N)