A grid layout tool offers every column count that divides the number of items evenly. To size the dropdown, it needs to know how many such counts exist.
Write countDivisors(n) that returns how many whole numbers from 1 to n divide n with no remainder.
Input: n = 12 Output: 6
1, 2, 3, 4, 6, and 12 divide 12.
Input: n = 1 Output: 1
Only 1 divides 1.
1 <= n <= 10^12Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #647 Count the Divisors. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.