|
|
A325887
|
|
Excess of sum of odd integers up to n and coprime to n over sum of even integers up to n and coprime to n.
|
|
1
|
|
|
1, 1, -1, 4, -2, 6, -3, 16, -1, 20, -5, 24, -6, 42, 4, 64, -8, 54, -9, 80, 6, 110, -11, 96, -2, 156, -1, 168, -14, 120, -15, 256, 10, 272, 12, 216, -18, 342, 12, 320, -20, 252, -21, 440, 4, 506, -23, 384, -3, 500, 16, 624, -26, 486, 20, 672, 18, 812, -29, 480, -30, 930, 6, 1024, 24
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,4
|
|
LINKS
|
|
|
FORMULA
|
a(n) = Sum_{k=1..n, gcd(k,n)=1} (-1)^(k+1)*k.
If n even, a(n) = n*phi(n)/2.
a(p^k) = floor(p/2) - p + 1, where p is odd prime.
If n is odd and n > 1, a(n) = mu(rad(n)) * phi(rad(n))/2 where rad(n) is the radical of n and mu is the Mobius function. - Tung T. Nguyen, Nov 10 2022
|
|
MATHEMATICA
|
a[n_] := Sum[Boole[GCD[k, n] == 1] (-1)^(k + 1) k, {k, 1, n}]; Table[a[n], {n, 1, 65}]
oiei[n_]:=Module[{cp=Select[Range[n-1], CoprimeQ[#, n]&]}, Total[Select[ cp, OddQ]]-Total[ Select[cp, EvenQ]]]; Join[{1}, Array[oiei, 70, 2]] (* Harvey P. Dale, Apr 23 2022 *)
|
|
PROG
|
(PARI) a(n)={sum(k=1, n, -if(gcd(k, n)==1, (-1)^k*k))} \\ Andrew Howroyd, Sep 07 2019
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|