Given an integer array nums, return the greatest common divisor of the smallest number and the largest number in nums. The greatest common divisor of two numbers is the largest positive integer that evenly divides both.
Given an integer array nums, return the greatest common divisor of the smallest number and the largest number in nums. The greatest common divisor of two numbers is the largest positive integer that evenly divides both.
Example 1:
Input: {"nums":[2,5,6,9,10]}
Output: 2
Constraints:
2≤nums.length≤1000
1≤nums[i]≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[2,5,6,9,10]}
Only the smallest and largest of the 5 numbers matter. Find them first.