MeetCode
GCD Of Array
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
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
Input
4 12 18 24 30
Output
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
Wrap
Copy
Start g=0 and set g=gcd(g,ai) for each element.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
4 12 18 24 30
Expected Output
6
Compile Output
Error
Output
Please
login
to submit solutions.