A scheduler wants the value in [L, R] that has the most divisors, because it offers the most ways to split a task evenly. Among all integers in the range, output the one with the greatest number of positive divisors. If several integers tie for the greatest divisor count, output the smallest of them.
A single line with two integers L and R.
A single integer: the value in [L, R] with the maximum divisor count (the smallest such value on a tie).
Example 1
Input
1 10
Expected
6
Explanation
The divisor counts peak at 4 for 6, 8, and 10; the smallest of these is 6.
Example 2
Input
2 6
Expected
6
Explanation
6 has four divisors (1,2,3,6), more than any other value in 2..6, so the answer is 6.
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 →