Bloomberg Interview Question

Write this code recursively, nested for loop time complexity, etc