%I #4 Mar 13 2020 20:27:29
%S 0,0,0,10,28,54,104,170,252,394,568,774,1068,1410,1800,2374,3028,3762,
%T 4656,5646,6732,8190,9792,11538,13636,15910,18360,21334,24532,27954,
%U 31856,36014,40428,45798,51504,57546,64228,71278,78696,87466,96700
%N Number of line segments connecting exactly 4 points in an n x n grid of points
%C a(n) is also the number of pairs of points visible to each other exactly through 2 points in an n x n grid of points.
%H S. Mustonen, <a href="http://www.survo.fi/papers/LinesInGrid2.pdf">On lines going through a given number of points in a rectangular grid of points</a>
%H Seppo Mustonen, <a href="/A141255/a141255.pdf">On lines going through a given number of points in a rectangular grid of points</a> [Local copy]
%F See Mathematica code.
%t j=3;
%t a[n_]:=a[n]=If[n<=j,0,2*a1[n]-a[n-1]+R1[n]]
%t a1[n_]:=a1[n]=If[n<=j,0,2*a[n-1]-a1[n-1]+R2[n]]
%t R1[n_]:=R1[n]=If[n<=j,0,R1[n-1]+4*S[n]]
%t R2[n_]:=(n-1)*S[n]
%t S[n_]:=If[Mod[n-1,j]==0,EulerPhi[(n-1)/j],0]
%t Table[a[n],{n,1,50}]
%K nonn
%O 1,4
%A _Seppo Mustonen_, May 13 2010