%I #20 Aug 21 2021 13:18:50
%S 8,28,80,178,372,654,1124,1782,2724,3914,5580,7626,10352,13590,17540,
%T 22210,28040,34670,42760,51962,62612,74494,88508,104042,121912,141534,
%U 163664,187942,215636,245490,279260,316022,356456,399898,447612,498698,555352
%N Number of edges in a figure made up of a row of n adjacent congruent rectangles upon drawing diagonals of all possible rectangles.
%H Chai Wah Wu, <a href="/A331757/b331757.txt">Table of n, a(n) for n = 1..10000</a>
%H Lars Blomberg, Scott R. Shannon and N. J. A. Sloane, <a href="http://neilsloane.com/doc/rose_5.pdf">Graphical Enumeration and Stained Glass Windows, 1: Rectangular Grids</a>, (2020). Also arXiv:2009.07918.
%F a(n) = (2*n + 2 + 3*A324042(n) + 4*A324043(n))/2 [Corrected by _Chai Wah Wu_, Aug 16 2021]
%F For n > 1, a(n) = 2*(n*(n+3) + Sum_{i=2..floor(n/2)} (n+1-i)*(n+1+i)*phi(i) + Sum_{i=floor(n/2)+1..n} (n+1-i)*(2*n+2-i)*phi(i)). - _Chai Wah Wu_, Aug 16 2021
%t Table[n^2 + 4n + 1 + Sum[Sum[(2 * Boole[GCD[i, j] == 1] - Boole[GCD[i, j] == 2]) * (n + 1 - i) * (n + 1 - j), {j, 1, n}], {i, 1, n}], {n, 1, 37}] (* _Joshua Oliver_, Feb 05 2020 *)
%o (Python)
%o from sympy import totient
%o def A331757(n): return 8 if n == 1 else 2*(n*(n+3) + sum(totient(i)*(n+1-i)*(n+1+i) for i in range(2,n//2+1)) + sum(totient(i)*(n+1-i)*(2*n+2-i) for i in range(n//2+1,n+1))) # _Chai Wah Wu_, Aug 16 2021
%Y A306302 gives number of regions in the figure.
%Y This is column 1 of A331454.
%Y Cf. A324042, A324043.
%K nonn
%O 1,1
%A _N. J. A. Sloane_, Feb 04 2020