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 >= 3, a(n) = 4*z(n) - 4*z_2(n) + 12*n^2 - 24*n + 8. (This does not hold for n<3, because it uses Euler's formula, and the graph for n<3 has no hole, so has genus 0, whereas for n>=3 there is a hole and the graph has genus 1.) - Scott R. Shannon and N. J. A. Sloane, Mar 04 2020
LINKS
Jinyuan Wang, Table of n, a(n) for n = 1..1000
Scott R. Shannon, Colored illustration for a(3) = 152 (there are 152 vertices in this picture).
FORMULA
For n > 2, a(n) = 4*(n-1)*(3n-1)+12*Sum_{i=2..floor(n/2)} (n+1-i)*i*phi(i) + 4*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 5 elif n=2 then 27 else 12*n^2 - 24*n + 8 + 4*V(n, n, 1) - 4*V(n, n, 2); fi;
[seq(f(n), n=1..50)]; # N. J. A. Sloane, Mar 10 2020
PROG
(PARI) a(n) = if(n<3, 22*n - 17, 4*sum(i=1, n, sum(j=1, n, if(gcd(i, j)==1, (n+1-i)*(n+1-j), 0))) - 4*sum(i=1, n, sum(j=1, n, if(gcd(i, j)==2, (n+1-i)*(n+1-j), 0))) + 12*n^2 - 24*n + 8); \\ Jinyuan Wang, Aug 07 2021
(Python)
from sympy import totient
def A332598(n): return 22*n-17 if n <= 2 else 4*(n-1)*(3*n-1) + 12*sum(totient(i)*(n+1-i)*i for i in range(2, n//2+1)) + 4*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