Rapyd Interview Question

Write a recursion function, leetcode style.