day 8 - lucky lucky kind inputs

This commit is contained in:
alexchao26
2024-07-26 12:03:39 -04:00
parent d0ba1e3443
commit 906ed8a9ff
3 changed files with 237 additions and 0 deletions
+18
View File
@@ -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)
}