Pergunta de entrevista da empresa Infosys

Coding question for a pattern with recursive nature