Can you give us an explanation of your solution using recursion? It sounds like an interesting problem.