Problems > Smallest Divisor Above One > Editorial

Smallest Divisor Above One — Solution & Editorial

Back to the Problem

Trial division from 2 to √N; the first hit is the answer, and no hit means N is prime.

Complexity: O(√N)