Can u think of recursive algotithm to "Making Candies" of HackerRank?

Can anyone think of a recursive algorithm to solve this problem.
I am trying to figure out but I am not able to do it.

is it possible ?