GCD Exercise

51 views
Skip to first unread message

Michael Catanzaro

unread,
Jul 5, 2012, 9:00:20 PM7/5/12
to building-s...@googlegroups.com
There appears to be a problem with the GCD exercise in the chapter on functions: http://www.itmaybeahack.com/book/python-2.6/html/p01/p01c09_functions.html#function-exercises

This algorithm is an infinite loop - trace with p=4, q=2 to see why.

From your iterative version, the third step should be: if p > q, return GCD(p-q, q)

Thanks for the free book. :-)
Reply all
Reply to author
Forward
0 new messages