Created
January 9, 2019 08:00
-
-
Save seemcat/42f02123e144b495d5a2512e17cb48cf to your computer and use it in GitHub Desktop.
c0d3 solved in Go
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
func solution8(num1, num2 int) int { | |
var list []int | |
var biggerNum int | |
if num1 > num2 { | |
biggerNum = num1 | |
} else { | |
biggerNum = num2 | |
} | |
for i := 1; i < biggerNum; i++ { | |
if (num1 % i == 0 && num2 % i == 0) { | |
list = append(list, i) | |
} | |
} | |
max := list[0] | |
for _, value := range list { | |
if value > max { | |
max = value | |
} | |
} | |
return max | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment