functional programming principles in scala course - recursion