SAP Interview Question

A scenario was provided and I was asked to solve it using recursion