mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-19 03:23:27 +02:00
19 lines
261 B
Go
19 lines
261 B
Go
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)
|
|
}
|