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

%I #32 Dec 16 2022 11:52:26

%S 1,1,-1,4,-2,6,-3,16,-1,20,-5,24,-6,42,4,64,-8,54,-9,80,6,110,-11,96,

%T -2,156,-1,168,-14,120,-15,256,10,272,12,216,-18,342,12,320,-20,252,

%U -21,440,4,506,-23,384,-3,500,16,624,-26,486,20,672,18,812,-29,480,-30,930,6,1024,24

%N 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.

%H Antti Karttunen, <a href="/A325887/b325887.txt">Table of n, a(n) for n = 1..20000</a>

%F a(n) = Sum_{k=1..n, gcd(k,n)=1} (-1)^(k+1)*k.

%F If n even, a(n) = n*phi(n)/2.

%F a(p^k) = floor(p/2) - p + 1, where p is odd prime.

%F 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

%t a[n_] := Sum[Boole[GCD[k, n] == 1] (-1)^(k + 1) k, {k, 1, n}]; Table[a[n], {n, 1, 65}]

%t 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 *)

%o (PARI) a(n)={sum(k=1, n, -if(gcd(k,n)==1, (-1)^k*k))} \\ _Andrew Howroyd_, Sep 07 2019

%Y Cf. A000010, A002129, A023896, A038566, A098903, A007947 (positions of negative terms).

%K sign

%O 1,4

%A _Ilya Gutkovskiy_, Sep 07 2019

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 April 19 06:16 EDT 2024. Contains 371782 sequences. (Running on oeis4.)