FunctionRacerProblemsRace

GCD of Smallest and Largest

EasyMathPython, JavaScript, TypeScript, Java, C++

Find the smallest and the largest number in nums, and return the greatest common divisor of those two numbers.

Example 1

nums [2,5,6,9,10]
returns 2

gcd(2, 10) = 2.

Example 2

nums [7,5,6,8,3]
returns 1

gcd(3, 8) = 1.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems