Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Created June 5, 2016 10:58
Show Gist options
  • Save brettfreer/09d271a7783e2198e4c264cc20950233 to your computer and use it in GitHub Desktop.
Save brettfreer/09d271a7783e2198e4c264cc20950233 to your computer and use it in GitHub Desktop.
Return the greatest common denominator (GCD) of a list of integers A.
def GCD(a, b):
if b == 0:
return a
else:
return GCD(b, a%b)
gcd = reduce(lambda x, y: GCD(x, y), A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment