OFFSET
5,2
COMMENTS
Offset 5 is chosen to exclude the only count not divisible by 2, which represents the triangle with sides (2,3,4).
LINKS
David A. Corneth, Table of n, a(n) for n = 5..10000
FORMULA
PROG
(PARI) a(n) = {if(isprime(n), n\=2; return(n*(n-1)/2)); my(res = 0, g, sn = vecprod(factor(n)[, 1])); for(b = (n + 3)\2, n-1, g = gcd(b, sn); if(g == 1, res+=(2*b - n - 1); , my(d, e); d = divisors(g); for(i = 1, #d, e = (-1)^(omega(d[i])); t = ((b-1)\d[i])*e; t-= ((n-b)\d[i])*e; res+=t))); res>>1} \\ David A. Corneth, May 22 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Andrés Sancho and Hugo Pfoertner, May 21 2024
STATUS
approved