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

Return the two integers in any order.

&nbsp;
Example 1:

Input: num = 8
Output: [3,3]
Explanation: 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.


Example 2:

Input: num = 123
Output: [5,25]


Example 3:

Input: num = 999
Output: [40,25]


&nbsp;
Constraints:


	1 &lt;= num &lt;= 10^9


class Solution:
	def closestDivisors(self, num: int) -> List[int]:
		for i in range(int((num+2) ** (0.5)), 0, -1):  
			if not (num+1) % i: return [i, (num+1)//i] 
			if not (num+2) % i: return [i, (num+2)//i] 
		return []
class Solution {
    public int[] closestDivisors(int num) {
        int ans[]=new int[2];
        double a=Math.sqrt(num+1);
        double b=Math.sqrt(num+2);
        if(num==1){
            ans[0]=1;
            ans[1]=2;
            return ans;
        }
        else if(a%1==0){
            ans[0]=(int)a;
            ans[1]=(int)b;
            return ans;
        }
        else if(b%1==0){
            ans[0]=(int)b;
            ans[1]=(int)b;
             return ans;
        }
        else{
            int m=(int)Math.sqrt(num);
       int diff1=Integer.MAX_VALUE;
       int y=0,z=0,w=0,f=0;
       for(int i=2;i<=m;i++){
           if((num+1)%i==0){
               y=i;
               z=(num+1)/y;
               int r=Math.abs(y-z);
               if(r<diff1){
                   diff1=r;
               }
           }
       }
       int diff2=Integer.MAX_VALUE;
        for(int i=2;i<=m;i++){
           if((num+2)%i==0){
               w=i;
               f=(num+2)/w;
               int r=Math.abs(w-f);
               if(r<diff2){
                   diff2=r;
               }
           }
       }
            if(diff1<diff2){
                ans[0]=y;
            ans[1]=z;
                 return ans;
            }
            else{
                ans[0]=w;
                ans[1]=f;
                 return ans;
            }
        } 
    }
}```
class Solution 
{
	public:
	vector<int> findnumbers(int num)
	{
		int m=sqrt(num);
		while(num%m!=0)
		{
			m--;
		}
		return {num/m,m};
	}
	vector<int> closestDivisors(int num) 
	{
		vector<int> ans1=findnumbers(num+1);
		vector<int> ans2=findnumbers(num+2);
		if(abs(ans1[0]-ans1[1])<abs(ans2[0]-ans2[1]))
			return ans1;
		return ans2;
	}
};
/**
 * @param {number} num
 * @return {number[]}
 */
var closestDivisors = function(num) {
    const n1 = num + 1;
    const n2 = num + 2;

    let minDiff = Infinity;
    let result = [];
    for(let i = Math.floor(Math.sqrt(n2)); i >= 1; i--) {
        if(n1 % i === 0) {
            const diff = Math.abs(i - (n1 / i));
            if(diff < minDiff) {
                minDiff = diff;
                result = [i, n1 / i]
            }
        }

        if(n2 % i === 0) {
            const diff = Math.abs(i - (n2 / i));
            if(diff < minDiff) {
                minDiff = diff;
                result = [i, n2 / i]
            }
        }
    }

    return result;
};
Closest Divisors