Fi Money interview question

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