Added recursive solution

Added more elegant solution by using recursion.
Merge pull request #48 from filannim/patch-6

Added recursive solution