MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / Lcm

Function Lcm

math/lcm/lcm.go:10–12  ·  view source on GitHub ↗

Lcm returns the lcm of two numbers using the fact that lcm(a,b) * gcd(a,b) = | a * b |

(a, b int64)

Source from the content-addressed store, hash-verified

8
9// Lcm returns the lcm of two numbers using the fact that lcm(a,b) * gcd(a,b) = | a * b |
10func Lcm(a, b int64) int64 {
11 return int64(math.Abs(float64(a*b)) / float64(gcd.Iterative(a, b)))
12}

Callers 3

NewFunction · 0.92
testPreconditionFunction · 0.92
TestLcmFunction · 0.85

Calls 1

IterativeFunction · 0.92

Tested by 2

testPreconditionFunction · 0.74
TestLcmFunction · 0.68