Finding recursive formula for number of grid lines