This site is supported by donations to The OEIS Foundation. Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A141255 Total number of line segments between points visible to each other in a square n X n lattice. 3

%I

%S 0,6,28,86,200,418,748,1282,2040,3106,4492,6394,8744,11822,15556,

%T 20074,25456,32086,39724,48934,59456,71554,85252,101250,119040,139350,

%U 161932,187254,215136,246690,280916,319346,361328,407302,457180,511714,570232

%N Total number of line segments between points visible to each other in a square n X n lattice.

%C A line segment joins points (a,b) and (c,d) if the points are distinct and gcd(c-a,d-b)=1.

%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> [From _Seppo Mustonen_, May 13 2010]

%F a(n) = A114043(n) - 1.

%e The 2 x 2 square lattice has a total of 6 line segments: 2 vertical, 2 horizonal and 2 diagonal.

%t Table[cnt=0; Do[If[GCD[c-a,d-b]<2, cnt++ ], {a,n}, {b,n}, {c,n}, {d,n}]; (cnt-n^2)/2, {n,20}]

%t Contribution from _Seppo Mustonen_, May 13 2010: (Start)

%t (* This recursive code is much more efficient. *)

%t a[n_]:=a[n]=If[n<=1,0,2*a1[n]-a[n-1]+R1[n]]

%t a1[n_]:=a1[n]=If[n<=1,0,2*a[n-1]-a1[n-1]+R2[n]]

%t R1[n_]:=R1[n]=If[n<=1,0,R1[n-1]+4*EulerPhi[n-1]]

%t R2[n_]:=(n-1)*EulerPhi[n-1]

%t Table[a[n],{n,1,37}]

%t (End)

%Y Cf. A141224.

%K nonn

%O 1,2

%A _T. D. Noe_, Jun 17 2008

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified November 14 01:24 EST 2019. Contains 329108 sequences. (Running on oeis4.)