Added recursive solution

Added more elegant solution by using recursion.