ZapCom Group Interview Question

Recursive programming coding on the example given