Last active
July 30, 2023 22:05
-
-
Save dimitrilw/284fe2a69462177096245b72c6b9f102 to your computer and use it in GitHub Desktop.
Go (golang) greatest common denominator
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
// greatest common denominator | |
func gcd(a, b int) int { | |
if b > a { a, b = b, a } | |
if b == 0 { return a } | |
return gcd(b, a%b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment