cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A141255 #34 Dec 05 2022 20:49:51
%S A141255 0,6,28,86,200,418,748,1282,2040,3106,4492,6394,8744,11822,15556,
%T A141255 20074,25456,32086,39724,48934,59456,71554,85252,101250,119040,139350,
%U A141255 161932,187254,215136,246690,280916,319346,361328,407302,457180,511714,570232
%N A141255 Total number of line segments between points visible to each other in a square n X n lattice.
%C A141255 A line segment joins points (a,b) and (c,d) if the points are distinct and gcd(c-a,d-b)=1.
%D A141255 D. M. Acketa, J. D. Zunic: On the number of linear partitions of the (m,n)-grid. Inform. Process. Lett., 38 (3) (1991), 163-168. See Table A.1.
%D A141255 Jovisa Zunic, Note on the number of two-dimensional threshold functions, SIAM J. Discrete Math. Vol. 25 (2011), No. 3, pp. 1266-1268. See Eq. (1.2).
%H A141255 Chai Wah Wu, <a href="/A141255/b141255.txt">Table of n, a(n) for n = 1..10000</a>
%H A141255 Seppo 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]
%H A141255 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]
%H A141255 N. J. A. Sloane, <a href="/A115004/a115004.txt">Families of Essentially Identical Sequences</a>, Mar 24 2021 (Includes this sequence)
%F A141255 a(n) = A114043(n) - 1.
%F A141255 a(n) = 2*(n-1)*(2n-1) + 2*Sum_{i=2..n-1} (n-i)*(2n-i)*phi(i). - _Chai Wah Wu_, Aug 16 2021
%e A141255 The 2 x 2 square lattice has a total of 6 line segments: 2 vertical, 2 horizontal and 2 diagonal.
%t A141255 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 A141255 (* This recursive code is much more efficient. *)
%t A141255 a[n_]:=a[n]=If[n<=1,0,2*a1[n]-a[n-1]+R1[n]]
%t A141255 a1[n_]:=a1[n]=If[n<=1,0,2*a[n-1]-a1[n-1]+R2[n]]
%t A141255 R1[n_]:=R1[n]=If[n<=1,0,R1[n-1]+4*EulerPhi[n-1]]
%t A141255 R2[n_]:=(n-1)*EulerPhi[n-1]
%t A141255 Table[a[n],{n,1,37}]
%t A141255 (* _Seppo Mustonen_, May 13 2010 *)
%t A141255 a[n_]:=2 Sum[(n-i) (n-j) Boole[CoprimeQ[i,j]], {i,1,n-1}, {j,1,n-1}] + 2 n^2 - 2 n; Array[a, 40] (* _Vincenzo Librandi_, Feb 05 2020 *)
%o A141255 (Python)
%o A141255 from sympy import totient
%o A141255 def A141255(n): return 2*(n-1)*(2*n-1) + 2*sum(totient(i)*(n-i)*(2*n-i) for i in range(2,n)) # _Chai Wah Wu_, Aug 16 2021
%Y A141255 Cf. A141224.
%Y A141255 The following eight sequences are all essentially the same. The simplest is A115004(n), which we denote by z(n). Then A088658(n) = 4*z(n-1); A114043(n) = 2*z(n-1)+2*n^2-2*n+1; A114146(n) = 2*A114043(n); A115005(n) = z(n-1)+n*(n-1); A141255(n) = 2*z(n-1)+2*n*(n-1); A290131(n) = z(n-1)+(n-1)^2; A306302(n) = z(n)+n^2+2*n. - _N. J. A. Sloane_, Feb 04 2020
%K A141255 nonn
%O A141255 1,2
%A A141255 _T. D. Noe_, Jun 17 2008