Created
June 5, 2016 10:58
-
-
Save brettfreer/09d271a7783e2198e4c264cc20950233 to your computer and use it in GitHub Desktop.
Return the greatest common denominator (GCD) of a list of integers A.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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