login
a(n) = Sum_{k=0..n}(n^[not(k | n)] - n^[k | n]), where '[ ]' denotes the Iverson bracket.
5

%I #40 Aug 06 2023 08:15:56

%S 1,0,-1,0,-3,8,-5,24,7,32,27,80,11,120,91,112,105,224,119,288,171,280,

%T 315,440,207,480,475,520,459,728,435,840,651,832,891,952,665,1224,

%U 1147,1216,975,1520,1107,1680,1419,1496,1755,2024,1363,2112,1911,2200,2091

%N a(n) = Sum_{k=0..n}(n^[not(k | n)] - n^[k | n]), where '[ ]' denotes the Iverson bracket.

%H Peter Luschny, <a href="/A363421/b363421.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = n^2 - 2*(n - 1)*tau(n) - 1 for n >= 1, where tau = A000005.

%t A363421[n_]:=If[n==0,1,n^2-2(n-1)DivisorSigma[0,n]-1];Array[A363421,100,0] (* _Paolo Xausa_, Aug 06 2023 *)

%o (SageMath)

%o print([sum(n^(not k.divides(n)) - n^k.divides(n) for k in srange(n+1)) for n in srange(53)])

%o (Python)

%o from sympy import divisor_count

%o def A363421(n): return n**2-2*(n-1)*divisor_count(n)-1 if n else 1 # _Chai Wah Wu_, Jun 28 2023

%Y Cf. A000005, A113704, A363734, A363735.

%K sign

%O 0,5

%A _Peter Luschny_, Jun 27 2023