Check whether a positive integer is prime in O(sqrt(n)) time
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
Overview: Decide whether a positive integer up to one billion is prime while checking candidate divisors only up to its square root. It tests the factor-pair argument behind that bound, correct handling of 1, 2 and perfect squares, and a loop condition free of off-by-one errors.