Problem_24 solution with recursion!