MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Extended

Function Extended

math/gcd/extended.go:14–20  ·  view source on GitHub ↗

Extended simple extended gcd

(a, b int64)

Source from the content-addressed store, hash-verified

12
13// Extended simple extended gcd
14func Extended(a, b int64) (int64, int64, int64) {
15 if a == 0 {
16 return b, 0, 1
17 }
18 gcd, xPrime, yPrime := Extended(b%a, a)
19 return gcd, yPrime - (b/a)*xPrime, xPrime
20}

Callers 2

InverseFunction · 0.92
TestExtendedFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExtendedFunction · 0.68