Greatest Common Divisor
Given a list of positive integers nums
, return the largest positive integer that divides each of the integers.
Constraints
1 ≤ n ≤ 100,000
wheren
is the length ofnums
https://binarysearch.com/problems/Greatest-Common-Divisor
Examples
Example 1
Input
- nums =
[6, 12, 9]
Output
- answer =
3
Explanation
3
is the largest integer that divides into 6
, 12
, and 9
.
Example 2
Input
- nums =
[6, 7, 9]
Output
- answer =
1
Explanation
7
is a prime number so only 1
divides into it.
Leave a comment