Capgemini Interview Question

Aked to write a python code using recursive functions