Domanda di colloquio di Instructure

How would you code this recursively versus iteratively?