I moved this thread as it has nothing to do with recursion.

Which part of this fails? Break the problem down into smaller steps so you know exactly where the program fails.