Argh!! *You've been programming for too long in procedural languages!! *Recursion is definitely cool and something you can never completely understand. There are so many things you can do with recursive logic that are much more difficult in iterative logic. *While it is true that you can convert nearly any recursive algorithm to an iterative algorithm, it is not true that the iterative version is necessarily better or more optimized. *Often times, when you convert a recursive solution to an iterative solution, there are many cases in which you end up doing nothing more than what the compiler or interpretter would have done anyways with the recursive solution (i.e. pushing stuff on a stack.)
I don't even know what tail recursive is. *And I can't "tell" the first function.
If n is 0, then return 0, else, add the current value of m with the value of the function mult given paramters n-1 and m. *This is seriously messing with my head... *Recursion can be such a pain at times. *A good ol' loop would be so much better IMO.
I read somewhere, the following which I thought did a very good job of illustrating recursion in very simple terms:
I want you to perform an experiment, that hopefully will help you to understand recursion. *Get two rather large mirrors and have them face each other (with enough distance so that you can walk between them.) *What you see is a real life example of recursion in the real world.
A child couldn't sleep, so her mother told her a story about a little frog,
****who couldn't sleep, so the frog's mother told her a story about a little bear,
******** who couldn't sleep, so the bear's mother told her a story about a little weasel...
************who fell asleep.
********...and the little bear fell asleep;
****...and the little frog fell asleep;
...and the child fell asleep.
The other thing to do is to go look at a few MC Escher paintings. *Many of his paintings are, in a sense, recursive in nature. *They are beautiful paintings that will throw your head against the wall just so you can try to understand them.
PS Once you understand recursion, I'll be happy to explain tail recursion. *It's difficult to understand tail recursion if you do not understand recursion.