p03 solved using recursion