OFFSET
0,6
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
MAPLE
MATHEMATICA
a[n_] := Sum[If[Divisible[n, n - k], 0, k^2], {k, 0, n - 1}]
Table[a[n], {n, 0, 46}]
PROG
(SageMath)
def A367327(n): return sum(k^2 for k in (0..n-1) if not (n-k).divides(n))
print([A367327(n) for n in range(47)])
(Python)
from math import prod
from sympy import factorint
def A367327(n):
f = factorint(n).items()
return n*(n-1)*((n<<1)-1)//6-n*(n*prod(e+1 for p, e in f)-(prod((p**(e+1)-1)//(p-1) for p, e in f)<<1))-prod((p**(e+1<<1)-1)//(p**2-1) for p, e in f) if n else 0 # Chai Wah Wu, Nov 14 2023
(PARI) a(n) = sum(k=0, n-1, if (n % (n-k), k^2)); \\ Michel Marcus, Nov 15 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Nov 14 2023
STATUS
approved