Instructure Interview Question

How would you code this recursively versus iteratively?