Solve recurrence relation