Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #17 Nov 15 2023 01:52:24
%S 0,0,0,1,1,14,5,55,39,104,115,285,104,506,457,575,611,1240,790,1785,
%T 1204,1950,2349,3311,1746,3924,4155,4625,4312,6930,4375,8555,6939,
%U 9032,10127,10845,7887,14910,14549,15603,12730,20540,15273,23821,20648,21874,26905
%N a(n) = Sum_{(n - k) does not divide n, 0 <= k < n} k^2.
%H Michael De Vlieger, <a href="/A367327/b367327.txt">Table of n, a(n) for n = 0..10000</a>
%F A367326(n+1) + a(n+1) = A000330(n).
%p divides := (k, n) -> k = n or (k > 0 and irem(n, k) = 0):
%p A367327 := n -> local k; add(`if`(divides(n - k, n), 0, k^2), k = 0..n - 1):
%p seq(A367327(n), n = 0..61);
%t a[n_] := Sum[If[Divisible[n, n - k], 0, k^2], {k, 0, n - 1}]
%t Table[a[n], {n, 0, 46}]
%o (SageMath)
%o def A367327(n): return sum(k^2 for k in (0..n-1) if not (n-k).divides(n))
%o print([A367327(n) for n in range(47)])
%o (Python)
%o from math import prod
%o from sympy import factorint
%o def A367327(n):
%o f = factorint(n).items()
%o 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
%o (PARI) a(n) = sum(k=0, n-1, if (n % (n-k), k^2)); \\ _Michel Marcus_, Nov 15 2023
%Y Cf. A367327, A000330, A024816.
%K nonn
%O 0,6
%A _Peter Luschny_, Nov 14 2023