Fi Money Interview Question

Coding question solved using recursion(I haven't seen this question before)