A community garden has planted exactly n saplings along a single straight path, one after another. The groundskeeper wants to instead line them up as a rectangular grid: pick some number of rows R (with 1 <= R <= n), and place the same number of saplings in every row, using all n saplings and leaving none out. Given n, determine whether there are exactly three different values of R for which such an equal-row arrangement is possible.
A single line containing one integer n.
Print true if exactly three values of R admit a valid equal-row arrangement of the n saplings; otherwise print false.
1 <= n <= 10^4
Example 1
Input
4
Expected
true
Explanation
4 saplings can be arranged into 1 row of 4, 2 rows of 2, or 4 rows of 1 — exactly three distinct row counts — so the answer is true.
Example 2
Input
6
Expected
false
Explanation
6 saplings admit four arrangements (1x6, 2x3, 3x2, 6x1), which is not exactly three, so the answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →