login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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
Cf. A000010, A002129, A023896, A038566, A098903, A007947 (positions of negative terms).
Sequence in context: A308712 A275845 A281978 * A209877 A273667 A187109
KEYWORD
sign
AUTHOR
Ilya Gutkovskiy, Sep 07 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 29 09:16 EDT 2024. Contains 375511 sequences. (Running on oeis4.)