OFFSET
2,2
COMMENTS
This seems to be (-1)^(n+1) times h(-4n^2) = (-1)^(n+1)*A000003(n^2), where h(k) is the class number. Verified for n <= 10^5. - Charles R Greathouse IV, Apr 28 2013
LINKS
Amiram Eldar, Table of n, a(n) for n = 2..10000
Stanley Rabinowitz, Problem 2129, Crux Mathematicorum, Vol. 22, No. 3 (1996), p. 123; Solution to Problem 2129, by G. P. Henderson and Kurt Girstmair, ibid., Vol. 23, No. 4 (1997), pp. 246-249.
FORMULA
a(n) = -A204617(n) if n is even, and A204617(n)/2 if n is odd (Rabinowitz, 1996). - Amiram Eldar, Mar 07 2022
MATHEMATICA
f[p_, e_] := p^(e - 1) * Switch[Mod[p, 4], 2, 1, 1, p - 1, 3, p + 1]; s[n_] := Times @@ f @@@ FactorInteger[n]; a[n_] := If[EvenQ[n], -s[n], s[n]/2]; Array[a, 100, 2] (* Amiram Eldar, Mar 07 2022 *)
PROG
(PARI) a(n)=round(real(1/4/I*sum(k=1, 4*n, (I^k)*tan(Pi/4/n*if(gcd(k, n)-1, 0, k)))))
(PARI) a(n)=round(imag(sum(k=1, 4*n, if(gcd(k, n)==1, I^k*tan(k*Pi/4/n))))/4) \\ Charles R Greathouse IV, Apr 25 2013
(PARI) a(n)=my(s); for(k=1, 2*n, if(gcd(2*k-1, n)==1, s-=(-1)^k*tan((2*k-1)*Pi/4/n))); round(s/4) \\ Charles R Greathouse IV, Apr 25 2013
CROSSREFS
KEYWORD
sign
AUTHOR
Benoit Cloitre, Aug 28 2003
EXTENSIONS
Definition corrected by Charles R Greathouse IV, Apr 25 2013
STATUS
approved