← Back to challenges

Find Greatest Common Divisor of N Numbers

PythonHardnumbersarraysmath

Instructions

Create a function that takes a list of numbers and returns the greatest common factor of those numbers.

Examples

gcd([84, 70, 42, 56]) ➞ 14

gcd([19, 38, 76, 133]) ➞ 19

gcd([120, 300, 95, 425, 625]) ➞ 5

Notes

The GCD is the largest factor that divides all numbers in the list.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.