Frage im Vorstellungsgespräch bei IBM

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