Why is the brute-force approach less ideal here?
Practice this question from Prime Check - Square Root Trial Division Pattern Practice Quiz, with options and an explanation.
Question
Why is the brute-force approach less ideal here?
Option A — Correct answer
Testing every divisor up to n - 1 wastes checks.
Option B
It always has better space complexity
Option C
It skips reading some inputs
Option D
It only works on strings
Explanation
Testing every divisor up to n - 1 wastes checks.