#C7414. Final GCD of Array Elements
Final GCD of Array Elements
Final GCD of Array Elements
You are given several test cases. For each test case, you are given an array of integers. Your task is to compute the greatest common divisor (GCD) of all the numbers in the array. The GCD of an array is defined as the result of applying the GCD operation between all elements sequentially.
Recall that the GCD of two numbers \(a\) and \(b\) is the largest integer that divides both \(a\) and \(b\) without leaving a remainder, and it can be computed using the Euclidean algorithm.
For each test case, print the final GCD in a new line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\) (\(1 \leq T \leq 100\)), the number of test cases.
- For each test case:
- The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)), the number of elements in the array.
- The second line contains \(n\) space-separated integers.
outputFormat
For each test case, output a single line containing the GCD of the array elements.
## sample2
3
10 7 12
4
2 4 6 8
1
2
</p>