1979. Find Greatest Common Divisor of Array
Easy
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.
Example 1:
Example 2:
Example 3:
Constraints:
2 <= nums.length <= 1000
1 <= nums[i] <= 1000
解題
使用 Euclidean Algorithm (輾轉相除法) 來解。
Last updated