recursive solution of a function