Pergunta de entrevista da empresa Western Digital

coding question on logic about numbering