Attempt to make f iterative, add comment to recursive f