Skip to content

Instantly share code, notes, and snippets.

@dimitrilw
Last active July 30, 2023 22:05
Show Gist options
  • Save dimitrilw/284fe2a69462177096245b72c6b9f102 to your computer and use it in GitHub Desktop.
Save dimitrilw/284fe2a69462177096245b72c6b9f102 to your computer and use it in GitHub Desktop.
Go (golang) greatest common denominator
// 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