OFFSET
1,1
COMMENTS
See A331776 for many other illustrations.
Theorem. Let z(n) = Sum_{i, j = 1..n, gcd(i,j)=1} (n+1-i)*(n+1-j) (this is A115004) and z_2(n) = Sum_{i, j = 1..n, gcd(i,j)=2} (n+1-i)*(n+1-j) (this is A331761). Then, for n >= 2, a(n) = 8*z(n) - 4*z_2(n) + 28*n^2 - 44*n + 8. - Scott R. Shannon and N. J. A. Sloane, Mar 06 2020
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
Scott R. Shannon, Colored illustration for a(3) = 360 (there are 360 edges in this picture).
FORMULA
For n > 1, a(n) = 4*(n-1)*(8*n-1) + 8*Sum_{i=2..floor(n/2)} (n+1-i)*(n+i+1)*phi(i) + 8*Sum_{i=floor(n/2)+1..n} (n+1-i)*(2*n+2-i)*phi(i). - Chai Wah Wu, Aug 16 2021
MAPLE
V := proc(m, n, q) local a, i, j; a:=0;
for i from 1 to m do for j from 1 to n do
if gcd(i, j)=q then a:=a+(m+1-i)*(n+1-j); fi; od: od: a; end;
f := n -> if n=1 then 8 else 28*n^2 - 44*n + 8 + 8*V(n, n, 1) - 4*V(n, n, 2); fi;
[seq(f(n), n=1..50)]; # N. J. A. Sloane, Mar 10 2020
PROG
(Python)
from sympy import totient
def A332597(n): return 8 if n == 1 else 4*(n-1)*(8*n-1) + 8*sum(totient(i)*(n+1-i)*(n+i+1) for i in range(2, n//2+1)) + 8*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
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon and N. J. A. Sloane, Mar 02 2020
EXTENSIONS
More terms from N. J. A. Sloane, Mar 10 2020
STATUS
approved