solution for basic recursion problem