Pregunta de entrevista de IBM

Can you solve this Python script problem using a recursive function instead of loops?