<p>Given an integer <code>num</code>, find the closest two integers in absolute difference whose product equals&nbsp;<code>num + 1</code>&nbsp;or <code>num + 2</code>.</p>

<p>Return the two integers in any order.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> num = 8
<strong>Output:</strong> [3,3]
<strong>Explanation:</strong> For num + 1 = 9, the closest divisors are 3 &amp; 3, for num + 2 = 10, the closest divisors are 2 &amp; 5, hence 3 &amp; 3 is chosen.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> num = 123
<strong>Output:</strong> [5,25]
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> num = 999
<strong>Output:</strong> [40,25]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= num &lt;= 10^9</code></li>
</ul>

from typing import List

class Solution:
    def closestDivisors(self, num: int) -> List[int]:
        # Iterate from the square root of (num + 2) down to 1
        for i in range(int((num + 2) ** 0.5), 0, -1):
            # Check if i is a divisor of (num + 1)
            if (num + 1) % i == 0:
                # If true, return the pair of divisors for (num + 1)
                return [i, (num + 1) // i]
            # Check if i is a divisor of (num + 2)
            if (num + 2) % i == 0:
                # If true, return the pair of divisors for (num + 2)
                return [i, (num + 2) // i]

# Solution steps:
# 1. We need to find two integers whose product is either num + 1 or num + 2.
# 2. The goal is to find the pair of divisors with the smallest absolute difference.
# 3. To achieve this, we iterate from the square root of (num + 2) down to 1.
# 4. For each integer i in this range, we check if it divides (num + 1) or (num + 2) without a remainder.
# 5. If i is a divisor, we calculate the corresponding pair (i, (num + 1) // i) or (i, (num + 2) // i).
# 6. The first valid pair found will have the smallest difference due to the iteration starting from the square root.
# 7. Return the pair of divisors as the result.

# Example usage:
# solution = Solution()
# print(solution.closestDivisors(8))   # Output: [3, 3]
# print(solution.closestDivisors(123)) # Output: [5, 25]
# print(solution.closestDivisors(999)) # Output: [40, 25]
107