Instructure interview question

How would you code this recursively versus iteratively?