Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
egcd :: Integral i => i -> i -> (i, i) Source #
Returns (g, s) where g = gcd(a, b); as + bt = g. O(log min(a, b)). Also see note for egcd2.
egcd2 :: Integral i => i -> i -> (i, i, i) Source #
Returns (g, s, t) where g = gcd(a, b); as + bt = g. O(log min(a, b)). Note: If the inputs are negative the returned gcd may be negative. abs the inputs or sign flip the outputs if this is undesirable. The complexity assumes operations quotRem, (-), (*), (==0) all take O(1).