Recursive solution
Non-recursive functional