Pergunta de entrevista da empresa OCTO Technology

resolve this psuedo code with recursive way.