Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.

The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.

&nbsp;
Example 1:

Input: nums = [2,5,6,9,10]
Output: 2
Explanation:
The smallest number in nums is 2.
The largest number in nums is 10.
The greatest common divisor of 2 and 10 is 2.


Example 2:

Input: nums = [7,5,6,8,3]
Output: 1
Explanation:
The smallest number in nums is 3.
The largest number in nums is 8.
The greatest common divisor of 3 and 8 is 1.


Example 3:

Input: nums = [3,3]
Output: 3
Explanation:
The smallest number in nums is 3.
The largest number in nums is 3.
The greatest common divisor of 3 and 3 is 3.


&nbsp;
Constraints:


	2 &lt;= nums.length &lt;= 1000
	1 &lt;= nums[i] &lt;= 1000


class Solution:
    def findGCD(self, nums: List[int]) -> int:
        i_min = min(nums)
        i_max = max(nums)
        greater = i_max
        while True:
            if greater % i_min == 0 and greater % i_max == 0:
                lcm = greater
                break
            greater += 1
        return int(i_min/(lcm/i_max))
class Solution {
    public int findGCD(int[] nums) {
        Arrays.sort(nums);
        int n=nums[nums.length-1];
        int result=nums[0];
        while(result>0){
            if(nums[0]%result==0 && n%result==0){
                break;
            }
            result--;
        }
        return result;
    }
}
class Solution {
public:
    int findGCD(vector<int>& nums) {
        int mn = nums[0], mx = nums[0];
        for(auto n: nums)
        {
            // finding maximum, minimum values of the array.
            if(n > mx) mx = n;
            if(n < mn) mn = n;
        }

        for(int i = mn; i >= 1; i--)
        {
            // finding greatest common divisor (GCD) of max, min.
            if((mn % i == 0) && (mx % i == 0)) return i;
        }
        return 1;
    }
};
var findGCD = function(nums) {
    let newNum = [Math.min(...nums) , Math.max(...nums)]
    let firstNum = newNum[0]
    let secondNum = newNum[1]
    while(secondNum) {
    let newNum = secondNum;
    secondNum = firstNum % secondNum;
    firstNum = newNum;
  }
   return firstNum
};
Find Greatest Common Divisor of Array