Bloomberg interview question

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