#K58797. Greatest Common Divisor Over Multiple Datasets
Greatest Common Divisor Over Multiple Datasets
Greatest Common Divisor Over Multiple Datasets
You are given several datasets. Each dataset begins with an integer N representing the number of subsequent integers, followed by N integers. Your task is to compute the greatest common divisor (GCD) for each dataset.
The GCD of two numbers a and b is defined as the largest positive integer that divides both a and b without leaving a remainder. It is often represented using the formula: $$\gcd(a,b)=\max\{d\in \mathbb{N}: d\mid a \text{ and } d\mid b\}.$$
For each dataset, print the computed GCD on a new line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer T representing the number of datasets.
- Then T lines follow, each describing a dataset. Each dataset line starts with an integer N (the number of elements) followed by N integers.
outputFormat
For each dataset, output the GCD computed for the provided list of integers on a new line, using standard output (stdout).
## sample1
1 7
7
</p>