mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-19 03:23:27 +02:00
day 8 - lucky lucky kind inputs
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package mathy
|
||||
|
||||
func LeastCommonMultiple(i, j int) int {
|
||||
gcd := GreatestCommonMultiple(i, j)
|
||||
|
||||
return (i * j) / gcd
|
||||
}
|
||||
|
||||
func GreatestCommonMultiple(i, j int) int {
|
||||
if j > i {
|
||||
i, j = j, i
|
||||
}
|
||||
|
||||
if j == 0 {
|
||||
return i
|
||||
}
|
||||
return GreatestCommonMultiple(j, i%j)
|
||||
}
|
||||
Reference in New Issue
Block a user