How to solve it using recursion?

iteratively I solved it, how to convert iterative code to recursive code??

This is hard to solve through recursion. It is a iterative question. It is good if ou solve this problem iteartive. Recursive problems are in different section. Practise them for recursion.