Find Greatest Common Divisor of N Numbers

Published by _fluffyy in

Create a function that takes an array 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 array.

Watch a quick demo on how Edabit works.