ExtendedIterative finds and returns gcd(a, b), x, y satisfying a*x + b*y = gcd(a, b).
(a, b int64)
| 2 | |
| 3 | // ExtendedIterative finds and returns gcd(a, b), x, y satisfying a*x + b*y = gcd(a, b). |
| 4 | func ExtendedIterative(a, b int64) (int64, int64, int64) { |
| 5 | var u, y, v, x int64 = 1, 1, 0, 0 |
| 6 | for a > 0 { |
| 7 | var q int64 = b / a |
| 8 | x, u = u, x-q*u |
| 9 | y, v = v, y-q*v |
| 10 | b, a = a, b-q*a |
| 11 | } |
| 12 | return b, x, y |
| 13 | } |
nothing calls this directly
no outgoing calls
no test coverage detected