Pregunta de entrevista de Infosys

Coding question for a pattern with recursive nature