I'm a little surprised that code doesn't result in a stack overflow (it looks like it should from visual inspection).

In a recursive algorithm, you must check for the base case(s) first. I don't...