Some formulas for numbers of line segments and lines in a rectangular   grid
  We present a formula for the number of line segments connecting q+1 points of an n_1 x...x n_k rectangular grid. As corollaries, we obtain formulas for the number of lines through at least q points and, respectively, through exactly q points of the grid. The well-known case k=2 is so generalized. We also present recursive formulas for these numbers assuming k=2, n_1=n_2. The well-known case q=2 is so generalized. 
Pentti Haukkanen and Jorma K. Merikoski
math.CO math.NT