Pregunta de entrevista de Tata Consultancy Services

a very basic programming problem