Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Euler's version of gcd be tail-recursive? #27

Open
klaeufer opened this issue Mar 17, 2015 · 1 comment
Open

Can't Euler's version of gcd be tail-recursive? #27

klaeufer opened this issue Mar 17, 2015 · 1 comment
Assignees
Labels

Comments

@klaeufer
Copy link
Member

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

@gkthiruvathukal
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants