You are given a positive integer N. Your task is to return the smallest number in the range from 1 to N that has the greatest number of positive divisors. If multiple numbers share the maximum divisor count, return the smallest one.
Input: N = 10
Output: 6
Explanation: The number 6 has four positive divisors: 1, 2, 3, and 6. No number from 1 to 10 has more than four divisors, and 6 is the smallest number with this maximum count.
Input: N = 15
Output: 12
Explanation: The number 12 has six positive divisors: 1, 2, 3, 4, 6, and 12. This is the maximum divisor count in the range from 1 to 15.
Input: N = 1
Output: 1
Explanation: The only candidate is 1, which has exactly one positive divisor.
Sign in to write, run, and submit your solution against the full test suite.