problem 3 using recursion