To whom it may concern, Hi, I've just started learning how to program in python using Allan B. Downy's book "How to think like a computer scientist" and it explained something in the recursion chapter which have still been unable to understand. It wrote a piece of code for the factorial function in math for example 3! is 3 * 2 * 1. I cannot understand the how it claimed the code executed, and logically it makes no sense to me. Please explain it to me, as I have spent hours trying to get my head around it, as the book(in my opinion) did not explain it well. Here it is: def factorial(n): if n == 0: return 1 else: recurse = factorial(n-1) result = n * recurse return result If there is and easier piece of code that you know of that can be used for factorial, if you could please also tell me that. Thank you for your time.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor