solve recurrence relation