Dsa
Math
Easy
GCD of List of Numbers
Given a list of integers, calculate the greatest common divisor (GCD) of the entire list. The GCD of a list of integers is the largest positive integer that divides each of the integers in the list without leaving a remainder.
Input Format:
- The first line contains an integer N (1 <= N <= 1000), the number of integers in the list.
- The second line contains N space-separated integers (1 <= each integer <= 10000).
Output Format:
- Print the GCD of the list of integers.
Example:
Input:
3
12 15 9
Output:
3
(Explanation: The GCD of 12, 15, and 9 is 3).
Key concepts
mathgcdlists
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now