You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for suggesting this. The original C# version was designed only for positive (well, non-negative, because you do have a base case at x=0) inputs. Technically, this might be more true to Euclid's original algorithm.
https://github.com/LoyolaChicagoBooks/introcs-scala-examples/blob/master/gcd/gcd.scala#L5
There is a more general tail-recursive version here, as well as a simpler one for positive arguments:
http://en.wikipedia.org/wiki/Greatest_common_divisor#Using_Euclid.27s_algorithm
The text was updated successfully, but these errors were encountered: