xxxxxxxxxx
Solve the problem using loops first.
From that, extract the possible inputs if you would turn this into a function.
Deduct the simplest version of the problem.
Write a function that solves the simplest instance of that problem.
Use that function to write a new recursive function.