Tesnet Group interview question

A simple task with resccurency