GCD Of Array

GCD Of Array

Medium Computer Mathematics GCD/LCM & Euclid 31 views
Explanation Complexity

Problem Statement

Given n and n integers, print gcd of all numbers.

Input Format

n then n integers.

Output Format

One integer gcd.

Example

4
12 18 24 30
6

Constraints

1

Input / Output Format

Input Format
n then n integers.
Output Format
One integer gcd.
Constraints
1

Examples

Input:
4 12 18 24 30
Output:
6

Example Solution (Public)

Computer Mathematics
Start g=0 and set g=gcd(g,ai) for each element.

Official Solution Code

Start g=0 and set g=gcd(g,ai) for each element.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.