Prove a primality test
Use the smallest-factor argument and respect the input bounds.
Understand the idea
A prime is an integer at least 2 with exactly two positive divisors. Every composite n has a factor at most √n: if both factors exceeded √n, their product would exceed n. Trial division needs only possible divisors through that boundary.
Trace a small example
For 49, testing only d < √n misses 7 and wrongly calls it prime. The inclusive condition d ≤ n/d catches the divisor. Reject 0 and 1 before entering a loop that might do no work.
Conditions and cost
Trial division is O(√n) worst-case. A 64-bit type does not make the loop fast for arbitrary 64-bit inputs. Include the number of queries in the cost estimate. For many bounded queries, prepare a sieve.
Which value exposes omitting the square-root boundary?
Turn the idea into code
Is 97 prime? State the divisors that need testing.
Give me a hint
The integer square-root boundary is 9.
Show the explained solution
Yes. No integer from 2 through 9 divides 97. Testing only primes 2, 3, 5, 7 also suffices if the prime list is complete.
Your notes
Mark complete when you can explain it yourself.