IBM interview question

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