--- Joe Riopel <[EMAIL PROTECTED]> wrote: > How about this one for recursion and control flow: > > >>> def hcd(m,n): > ... r = m % n > ... if( r > 0 ): > ... hcd(n, r) > ... else: > ... print "hcd = %d" % (n,) > ... > >>> hcd(119, 544) > hcd = 17 > >>> > > It calculates the highest common denominator for m > and n. Plus it's E1 > in TAoCP by Knuth. >
I'm a little wary of having the page contain too many mathematical examples, although I admit that I've already included Fibonacci and Eratosthenes. (And your example shares in common with those two that it's a classic example.) Feel free to post your example on the page, but please use slightly more descriptive identifiers (e.g. change hcd to highest_common_denominator or largest_common_denominator), and also have the program print out the results. Thanks. -- Steve ____________________________________________________________________________________ Yahoo! oneSearch: Finally, mobile search that gives answers, not web links. http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC -- http://mail.python.org/mailman/listinfo/python-list