Summing Pieces | HackerRank

How to think of a recurrence relation for this type of questions.