Find Greatest Common Divisor of Array Problem

Find Greatest Common Divisor of Array Problem — ExecCode Easy DSA Practice

Solve the Find Greatest Common Divisor of Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. Your task is to the greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers. Return the required answer exactly as shown in the examples.

Examples

Input {"nums": [2, 5, 6, 9, 10]}; Output 2. Input {"nums": [7, 5, 6, 8, 3]}; Output 1

Constraints

2 <= nums.length <= 1000 1 <= nums[i] <= 1000

Practice Find Greatest Common Divisor of Array free on ExecCode. Browse DSA problems, topic map, and placement guides.